# I need to connect to server via TCP

**URL:** <https://forums.unrealengine.com/t/i-need-to-connect-to-server-via-tcp/387279>\
**Category:** Multiplayer & Networking\
**Tags:** Networking, unreal-engine, question\
**Created:** [March 8, 2017, 7:11am UTC](https://forums.unrealengine.com/t/i-need-to-connect-to-server-via-tcp/387279 "2017-03-08T07:11:11Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mattlauk](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Mattlauk](https://forums.unrealengine.com/u/Mattlauk)\
**Post date:** [March 8, 2017, 7:11am UTC](https://forums.unrealengine.com/t/i-need-to-connect-to-server-via-tcp/387279/1 "2017-03-08T07:11:11Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Shadowriver](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Shadowriver](https://forums.unrealengine.com/u/Shadowriver)\
**Post date:** [March 8, 2017, 10:06am UTC](https://forums.unrealengine.com/t/i-need-to-connect-to-server-via-tcp/387279/2 "2017-03-08T10:06:14Z")

</div>

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:

> **[Sockets](https://docs.unrealengine.com/5.1/en-US/API/Runtime/Sockets/)**

Here oyu got some use examples from wiki

> **[A new, community-hosted Unreal Engine Wiki](https://forums.unrealengine.com/t/a-new-community-hosted-unreal-engine-wiki/141494)**
>
> After over a year in maintenance mode, the official Unreal Engine Wiki is now permanently offline. These resources now live on a new community-run Unreal Engine Community Wiki — https://unrealcommunity.wiki/! You will be able to find content from...

> **[A new, community-hosted Unreal Engine Wiki](https://forums.unrealengine.com/t/a-new-community-hosted-unreal-engine-wiki/141494)**
>
> After over a year in maintenance mode, the official Unreal Engine Wiki is now permanently offline. These resources now live on a new community-run Unreal Engine Community Wiki — https://unrealcommunity.wiki/! You will be able to find content from...

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

> **[Reading a file online](https://forums.unrealengine.com/questions/325380/reading-a-file-online.html)**
>
> I need to read a sequence of bytes stored in a basic txt file which can be found at a specific url. With a local file path I can use SaveFileToArray() function to store the bytes in a uint8 array, how can I do the same with the given file url?

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

---

<div class="post-metadata">

**Author:** ![Mattlauk](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Mattlauk](https://forums.unrealengine.com/u/Mattlauk)\
**Post date:** [March 9, 2017, 8:59am UTC](https://forums.unrealengine.com/t/i-need-to-connect-to-server-via-tcp/387279/3 "2017-03-09T08:59:23Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![c4tnt](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@c4tnt](https://forums.unrealengine.com/u/c4tnt)\
**Post date:** [March 9, 2017, 10:48am UTC](https://forums.unrealengine.com/t/i-need-to-connect-to-server-via-tcp/387279/4 "2017-03-09T10:48:28Z")

</div>

You can use

```
FString GetPlayerNetworkAddress();
FString GetServerNetworkAddress();

```

functions of PlayerController

---

<div class="post-metadata">

**Author:** ![Mattlauk](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Mattlauk](https://forums.unrealengine.com/u/Mattlauk)\
**Post date:** [March 11, 2017, 9:41am UTC](https://forums.unrealengine.com/t/i-need-to-connect-to-server-via-tcp/387279/5 "2017-03-11T09:41:44Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Salcalitarhana](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Salcalitarhana](https://forums.unrealengine.com/u/Salcalitarhana)\
**Post date:** [January 29, 2025, 2:47pm UTC](https://forums.unrealengine.com/t/i-need-to-connect-to-server-via-tcp/387279/6 "2025-01-29T14:47:06Z")

</div>

Links are dead
