Send message to open port in a server
We have a server opened in a specific port and I want to be able to send messages to that port from an external program.
However i cant get that program to connect to the server's port. The first solution i came up with was to create a listen socket to hear that entering one, and it works just fine.
So, to avoid using 2 ports, Can we implement aditional functionality throught that port to be called from an external program?
asked Jan 24 '19 at 12:14 PM in C++ Programming
Well you can't connect because UE4 use UDP protocol (not TCP), which does not formally connect to server just throws packets at destination, in fact there no concept of client and server on UDP layer it's just packet throwing and forget. This also means that it is packet loss tolerable unlike TCP and there no guaranty that packet will reach destination, while TCP monitors that and makes sure that packet lands even if this means large delay and waiting (or else internet really gonna cut off and connection gonna timeout). So if you want 100% sure that your data reach the server you should use TCP socket instead.
But if you really want to then get packets from game server you cna od that in UNetConnection class more specifically UIpConnection:
https://api.unrealengine.com/INT/API/Runtime/Engine/Engine/UNetConnection/index.html ...which you can process raw packets ReceivedRawPacket function and and you can be overrided from UNetDriver and UIpNetDriver
Which you can in engine.ini as demostratted here:
UNetConnection is extension of UPlayer, which represents the player it self (lower then APlayerController) so each player has it's own. Not sure if it's gonna accept packets from forgain ports. YOu relaly need to explore engine source code here.
Follow this question
Once you sign in you will be able to subscribe for any updates here