# \[Tutorial\] - Connecting to a Third Party Socket Server

**URL:** <https://forums.unrealengine.com/t/tutorial-connecting-to-a-third-party-socket-server/4951>\
**Category:** Community & Industry Discussion\
**Tags:** unreal-engine\
**Created:** [May 24, 2014, 5:51pm UTC](https://forums.unrealengine.com/t/tutorial-connecting-to-a-third-party-socket-server/4951 "2014-05-24T17:51:15Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![HailstoneRyan](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@HailstoneRyan](https://forums.unrealengine.com/u/HailstoneRyan)\
**Post date:** [May 24, 2014, 5:51pm UTC](https://forums.unrealengine.com/t/tutorial-connecting-to-a-third-party-socket-server/4951/1 "2014-05-24T17:51:15Z")

</div>

Finally got around to writing down how I was able to accomplish this. Hopefully it helps someone else and I hope people don’t mind a link to the wiki.

Wasn’t sure how to get it added to the list of tutorials on the wiki unfortunately.

> **[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 — ue4community.wiki! You will be able to find content from the official...

---

<div class="post-metadata">

**Author:** ![Dakkafex](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Dakkafex](https://forums.unrealengine.com/u/Dakkafex)\
**Post date:** [May 25, 2014, 1:42am UTC](https://forums.unrealengine.com/t/tutorial-connecting-to-a-third-party-socket-server/4951/2 "2014-05-25T01:42:26Z")

</div>

Maybe elaborate a little on what exactly this means and why should i use it.

---

<div class="post-metadata">

**Author:** ![Drexciya](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Drexciya](https://forums.unrealengine.com/u/Drexciya)\
**Post date:** [May 25, 2014, 11:28am UTC](https://forums.unrealengine.com/t/tutorial-connecting-to-a-third-party-socket-server/4951/3 "2014-05-25T11:28:26Z")

</div>

Use it to access external databases for persistent game worlds?

---

<div class="post-metadata">

**Author:** ![Dakkafex](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Dakkafex](https://forums.unrealengine.com/u/Dakkafex)\
**Post date:** [May 25, 2014, 1:59pm UTC](https://forums.unrealengine.com/t/tutorial-connecting-to-a-third-party-socket-server/4951/4 "2014-05-25T13:59:03Z")

</div>

yea but think of a new person, if you put things in context a little its always easier to understand.

---

<div class="post-metadata">

**Author:** ![HailstoneRyan](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@HailstoneRyan](https://forums.unrealengine.com/u/HailstoneRyan)\
**Post date:** [May 26, 2014, 1:55pm UTC](https://forums.unrealengine.com/t/tutorial-connecting-to-a-third-party-socket-server/4951/5 "2014-05-26T13:55:04Z")

</div>

Thanks for the feedback guys. I’ve added our specific use case to the page. We’re building a lobby/chat system that we felt using the built in dedicated server would have been overkill for.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_0074ae5e1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_0074ae5e1](https://forums.unrealengine.com/u/anonymous_user_0074ae5e1)\
**Post date:** [May 28, 2014, 2:42pm UTC](https://forums.unrealengine.com/t/tutorial-connecting-to-a-third-party-socket-server/4951/6 "2014-05-28T14:42:35Z")

</div>

Great tutorial. I’d move the dependency thing to the beginning though, since you should really do that first, right?

---

<div class="post-metadata">

**Author:** ![Rama](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/rama/32/882413_2.png) [@Rama](https://forums.unrealengine.com/u/Rama)\
**Post date:** [May 28, 2014, 5:07pm UTC](https://forums.unrealengine.com/t/tutorial-connecting-to-a-third-party-socket-server/4951/7 "2014-05-28T17:07:00Z")

</div>

Thanks for your awesome tutorial overlawled!

I’ve been wondering how this gets done, you did all the research for me!

I made your wiki tutorial publicly visible in both **Tutorials** and the **Code** section

Now people can easily find it when just browsing the 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 — ue4community.wiki! You will be able to find content from the official...

Thanks for sharing!

Rama

---

<div class="post-metadata">

**Author:** ![Moynzy](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Moynzy](https://forums.unrealengine.com/u/Moynzy)\
**Post date:** [November 5, 2015, 10:03am UTC](https://forums.unrealengine.com/t/tutorial-connecting-to-a-third-party-socket-server/4951/8 "2015-11-05T10:03:03Z")

</div>

Hi, I’ve been following this code, and I have found that when my c# server reads information from the client, it crashes.

When the server sends information to the client;

> [@](#):
>
> ```
> GEngine-&gt;AddOnScreenDebugMessage(-1, 5.f, FColor::Yellow, FString::FromInt(byteCount));
> 
> ```

The message is -1.#

Any ideas why :d/

---

<div class="post-metadata">

**Author:** ![Moynzy](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Moynzy](https://forums.unrealengine.com/u/Moynzy)\
**Post date:** [March 22, 2016, 1:53pm UTC](https://forums.unrealengine.com/t/tutorial-connecting-to-a-third-party-socket-server/4951/9 "2016-03-22T13:53:07Z")

</div>

Hi,

I can sent a message to my C# server.

After using the send() method, I sit there and wait for a reply back.

When the C# server gets a message, it will then send one back. My client misses the first packet received.

> [@](#):
>
> ```
> TArray&lt;uint8&gt; ReceivedData;
> 
> uint32 Size;
> while (mySocket-&gt;HasPendingData(Size))
> {
> ReceivedData.SetNumUninitialized(FMath::Min(Size, 65507u));
> 
> int32 Read = 0;
> mySocket-&gt;Recv(ReceivedData.GetData(), ReceivedData.Num(), Read);
> 
> //GEngine-&gt;AddOnScreenDebugMessage(-1, 5.f, FColor::Red, FString::Printf(TEXT("Data Read! %d"), ReceivedData.Num()));
> }
> // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> 
> if (ReceivedData.Num() &lt;= 0)
> {
> FString temp = TEXT("Error|Could not recieve from server.");
> 		
> 
> }
> 
> ```

Do you know I get a -1 the first time?

For e.g. I send the correct user credentials to my server, the server checks DB and sends true to UE4 client, UE4 client receives -1, despite the server saying “You can log in”?

Any clues,

Thank you.

---

<div class="post-metadata">

**Author:** ![Natsuki\_Chan](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Natsuki\_Chan](https://forums.unrealengine.com/u/Natsuki_Chan)\
**Post date:** [November 9, 2019, 4:16pm UTC](https://forums.unrealengine.com/t/tutorial-connecting-to-a-third-party-socket-server/4951/10 "2019-11-09T16:16:57Z")

</div>

Well I plan to upgrade my game but i want to connect the ue4 to my extrenal server that work on Microsoft Sql Server that why the way you say on page 1 can help with that?

---

<div class="post-metadata">

**Author:** ![SkyeEden](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/skyeeden/32/1116094_2.png) [@SkyeEden](https://forums.unrealengine.com/u/SkyeEden)\
**Post date:** [March 16, 2022, 12:34pm UTC](https://forums.unrealengine.com/t/tutorial-connecting-to-a-third-party-socket-server/4951/11 "2022-03-16T12:34:22Z")

</div>


