What Includes are needed to set up Networking and Sockets?
After following tutorials to set up a connection to a tcp socket server, I have added the following code to my Player Controller class:
but things like ISocketSubsystem and FIPv4Address were either undefined or incomplete types. I figured this means I needed to include their header files, so I used documentation to obtain their header file locations and added the includes within MyPlayerController.h as follows:
MyPlayerController.h includes (not including the auto-generated)
but including these files causes even more errors. I have tried just including Networking.h, and Sockets.h within their respective directories and it still has issues. I guess my question would be, what includes are needed to compile the above code, or is there an online resource which discusses including from modules such as Networking or Sockets? I'm very new to UE4 so I apologize if this question is trivial, but I've been stuck on this for hours so any help would be greatly appreciated. Thanks for reading!
You need the following includes:
The Socket API is a little difficult to use right now, but since you're already using it for most of your code anyway, you probably don't need the Networking module at all. The FinternetAddr class as a SetIp() overload that takes a string. Then you don't need the FIPv4Address.
If you're still getting compile errors, please post the errors.
answered Jun 06 '14 at 05:37 PM
FIPv4Address is defined in IPv4Address.h, which is included from Networking.h, but you may find it easier to use FInternetAddr exclusively. You can conveniently set the IP address with the SetIp function that takes a string as a parameter and avoid the dependency on FIPv4Address entirely. You may need to add an #include for IPAddress.h, which defines FInternetAddr.
If you're still getting errors, please post a specific error so we can better diagnose it.
Also, you should be able to use just the filename in your #include paths. The full path (starting at the Runtime directory) should be unnecessary if the corresponding module is declared as a dependency, which in your case it appears to be.
Follow this question
Once you sign in you will be able to subscribe for any updates here