Socket communication

Translated question (from Japanese):

Hello, this is my first post on the forum. I’m using a Mac and have difficulty in building a socket communication with Unreal Engine 4. Putting aside TCP, I’d like to establish a UDP communication first.

By referencing this thread, I added “Sockets” in .Build.cs of an Xcode project as shown below:

PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "Sockets" });

Then, as the local address was 192.168.0.2, I wrote:

FSocket *mySocket = FUdpSocketBuilder(TEXT("SomeDescription")) .BoundToAddress(FIPv4Address(192, 168, 0, 2)) .BoundToPort(22222) .Build();

However, the build failed in Xcode. The build error message was:

Command /Users/Shared/UnrealEngine/4.1/Engine/Build/BatchFiles/Mac/RocketBuild.sh failed with exit code 1

That was all I got, and I’m at a loss what to do.

Do I need to build a row socket of the operating system instead of using FUdpSocketBuilder? Though I was searching on the Internet, there was very little information about the issue even in English-speaking areas. I’d appreciate it if you could help me out. Thanks.

–Asked by selflash

Original Question

Using FUdpSocketBuilder should be sufficient. This class is a helper to make it easier to deal with the underlying Socket API in UE4. You will need to add a private module dependency to the Networking module in your Build.cs file if you wish to use this class.

As far as the build error goes, you would have to find out what exactly the build error is. I suspect that it is either a compiler or linker error due to the missing dependency to the Networking module.

I don’t have access to XCode right now, but there should be a way to see the actual output log of the compiler.

Could you please provide the necessary header files to compile a simple c++ project in Win7 referencing FUdpSocketBuilder because i already added 8 header files (i need to specify full path) and theres always a function nested inside each of these headers that need another include and so on… Whenever i quit researching i then open a new project and start over again. No go till now. My ultimate goal is to be able to communicate with my existing application that sends x,y coordinates via udp to my previous opengl app then im porting it to UE. i just want to read Strings from udp streams.

Yeah, it needs a cleanup pass for proper forward declarations and dependencies. The following includes should be sufficient:

#include "Networking.h"
#include "Sockets.h"
#include "SocketSubsystem.h"