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"

I need to connect to server via TCP

The project i am working on requires a TCP connection to the server. When a client connects to a session, how would I be able to get the ip address of the session connection to use to create my TCP connection?

Product Version: UE 4.14
Tags:
more ▼

asked Mar 08 '17 at 07:11 AM in Using UE4

avatar image

MJ_01
822 38 39 240

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

1 answer: sort voted first

In pure UE4 you can do this only via C++, in programming raw TCP/UDP network communication is usually called "sockets" (don't mistake with HTML Sockets which work bit different with incorporation of HTTP) so search using that name

UE4 has dedicated module for raw network communication called (supprice) "sockets", here API refrence:

https://docs.unrealengine.com/latest/INT/API/Runtime/Sockets/index.html

Here oyu got some use examples from wiki

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

If you plan using HTTP, UE4 has also dedicated module for that so you don't need to use raw TCP communication for it, here anwser that i posted in past showing how to use it

https://answers.unrealengine.com/questions/325380/reading-a-file-online.html

and i know UE4 plugin called VaRest which enables HTTP communication in blueprint with JSON parsing included

more ▼

answered Mar 08 '17 at 10:06 AM

avatar image

Shadowriver
35.2k 921 166 1098

avatar image MJ_01 Mar 09 '17 at 08:59 AM

I already know how to use sockets in eu4 for the most part. the only thing I need to know is how to connect my TCP socket to the session the client has connected to. specifically, I need the FInternetAddr that the client is connecting to.

Side question: Would be better for the client to create a listen socket and connect to that from the server? Either way, I need the FInternetAddr of the connection.

avatar image c4tnt Mar 09 '17 at 10:48 AM

You can use

 FString GetPlayerNetworkAddress();
 FString GetServerNetworkAddress();

functions of PlayerController

avatar image MJ_01 Mar 11 '17 at 09:41 AM

I think that's exactly what I am looking for.

(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