x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Unreal Engine TCP/UDP connection with another program

I have looked into the BSD Socket programming and researched the forum but still could not resolve my issue..Here is the thing

Blockquote

 void APizzaPizzaCharacter::Connect(){
     FSocket* Socket = ISocketSubsystem::Get(PLATFORM_SOCKETSUBSYSTEM)-CreateSocket(NAME_DGram, TEXT("default"), false);
 
     FString address = TEXT("127.0.0.1");
     int32 port = 6666;
     FIPv4Address ip;
     FIPv4Address::Parse(address, ip);
     auto addr = ISocketSubsystem::Get(PLATFORM_SOCKETSUBSYSTEM)->CreateInternetAddr();
     addr->SetIp(ip.GetValue());//setIP
     addr->SetPort(port);
 
     if (!Socket->Bind(*addr)){
         if (GEngine){
             GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Yellow, "Faied to bind socket");
         }
     }
     else{
         if (GEngine){
             GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Yellow, "Socket connect succesuflly");
         }
     }
     Socket->Close();
 }


Blockquote

I am running this Connect() in a default myCharacter.cpp. The ISSUE is that, despite the debug message shows socket is connected, the server, which is another program I wrote in C++, did not respond or receive its connection. The server is running on a winsock2. Please help me with that!! I have been working on it for days without progress....Thank you very very much!!

Product Version: Not Selected
Tags:
more ▼

asked Jul 11 '14 at 11:20 PM in C++ Programming

avatar image

DDQQ
1 2 3 4

(comments are locked)
10|2000 characters needed characters left

3 answers: sort voted first

You are not sending any data. Datagram (UDP) sockets are not "connected;" they just send data to a given address/port when you tell them to. That address/port will then, hopefully, receive the data, most of the time, assuming it is listening on that address/port and is also a UDP socket, and assuming that a route exists between the sender and the receiver (which, on the same machine, should be true :-)

more ▼

answered Jul 14 '14 at 04:54 PM

avatar image

jwatte
1.2k 48 38 87

(comments are locked)
10|2000 characters needed characters left

Complete Code Sample For You

I recently posted a completely functional code same for getting UE4 to receive data from a python script via a socket!

Hopefully this code sample can give you better sense of the API and how to work with it

in any case this is a fully functional TCP socket receiver system :)

https://wiki.unrealengine.com/TCP_Socket_Listener,_Receive_Binary_Data_From_an_IP/Port_Into_UE4,_(Full_Code_Sample)

Rama

more ▼

answered Jul 15 '14 at 12:41 AM

avatar image

Rama
10.5k 443 341 1078

avatar image yonsann Aug 05 '14 at 02:31 PM

Hi. There is nothing on the link you provided. Could you repost code sample ? Thanks!

avatar image undercover Aug 05 '14 at 03:59 PM
avatar image DDQQ Aug 13 '14 at 06:55 PM

Thanks!! I am trying that out!

avatar image DDQQ Aug 19 '14 at 10:15 PM

Thanks! it worked for me! have not yet tried to send from UE4 to other program reversely yet

avatar image marlo3_14 May 23 '15 at 05:21 PM

Dear all, I'm really new to UE4 and I would need your help. I'm trying to move an object on a scene by receiving it's desired position and orientation from an external program. Rama's TCP solution it's really nice and it seems the way to go. I was able to put the code con a custom Player Controller Class and it compiles fine, but since I'm really a newbie here I don't know how to proceed further. How can I actually run the code and use the received data to make an object move? I understand that I need something like a Pawn and use it with my custom PlayerController, but how can I link the two things?

Thanks for your help!

avatar image PTiengou Jul 10 '18 at 04:05 PM

Hi marlo3_14, I know this is a bit old, but I'm new to UE4 and am trying to do exactly what you were talking about here (updating a Pawn's position according to external data stream from another program). I wanted to know if you had succeeded, and what you used if possible. For now, I have managed to have a functional listening server thanks to Rama's tutorial (with a few modifications since I'm using UE4.18) and I'm about to go to the next steps. Are there any issued that I should be aware of ? Thanks for your help !

(comments are locked)
10|2000 characters needed characters left

someone help?

more ▼

answered Jul 14 '14 at 03:28 PM

avatar image

DDQQ
1 2 3 4

(comments are locked)
10|2000 characters needed characters left
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question