Low Entry Plugins

The 5 MB limit that is set on the buffer is set by me, since I figured, even at just 10 FPS the client is capable of a maximum of 50 MB/sec. Most people’s internet won’t even reach 5 MB/sec, let alone 50 MB/sec. Having a higher buffer has the downside that it uses more memory, so systems with less memory, or many socket connections open at once, can cause problems with that.

If you really need a higher speed than 5 MB per frame, then you can indeed have multiple socket connections open at once to the same server and same port, but I don’t see a possibility where that would ever be needed.

If the 5 MB/frame ever becomes a problem I’ll add a parameter to the Create Socket Connection blueprint to allow you to choose a receiving buffer size yourself, but currently that would over complicate something that you shouldn’t be bothered with (it gives you a reason, or even the need, to research what a receive buffer is, what the implications of a low or high buffer size is, etc, things you shouldn’t be focusing on or spending time on).

Every tick the Socket Connection plugin checks each Socket Connection to see if it still is connected, and if it isn’t, it will call the disconnected event.

The thing is though, is that TCP timeouts and disconnect packets are currently handled a bit weirdly in the UE4 socket code (made by Epic).
Instead of correctly handling TCP timeouts and disconnect packets, they just ignore them, and then the connection status still returns ‘Connected’, even though it isn’t.

Hopefully they will change this in the future, although I haven’t tested it in anything after 4.11.0 yet, so maybe it’s already fixed.

Either way, the best way to deal with timeouts and disconnects is to use Function Calls or Latent Function Calls, since they check for timeouts as well, which will always work no matter what.
If you send a Message, send a Connection Validation as well (or set Automatic Connection Validations to true/on, then it will send one every 30 seconds automatically).

Lastly, know that the socket code can work slightly different on every platform, because the low level socket connection implementation is different for each platform.
The biggest differences can be found between HTML and the rest, because HTML only supports async sockets, whereas the other implementations rely on being synchronizable. The other platforms should be pretty similar to each other.

Idealistically speaking, you wouldn’t notice a difference at all between different platforms, which is how it should eventually be, but currently there are some differences still.
For example, some platforms might handle disconnects properly while others ignore them, and some platforms might fail immediately when trying to connect to an invalid URL/port whereas some platforms return true (‘Connected’) even though they didn’t actually connect.

Sending and receiving packets will always work the same way on every platform however, the differences can only be found in the lower level workings of the socket connections.

Anyway, to test the major low level differences, you can do this:

  1. Test disconnect packets: on the server side call disconnect() onto a client, then see if the UE4 client fires the disconnected event.
  2. Test timeouts: while being connected, shutdown the server (kill the task), then see if the UE4 client fires the disconnected event.
  3. Test connecting to an invalid server: try to call connect on an invalid IP and port, like “example.com” and 5555 for example, then see if the connect blueprint returns false.

Some platforms will fail these tests, but know it’s probably best to not build workarounds for this yourself, since these differences will eventually be fixed and ironed out.

If you use Function Calls, Latent Function Calls, or Messages + Connection Validations, it will catch a fail of any of the tests described above.

Finally, if anyone can run these 3 tests on different platforms, please do and post the results here, that way I can see if there’s something I can do about it.
I’ve only tested Windows and HTML thoroughly (and only on 4.11.0 and older), so if anyone could test this out as well on different UE versions and on different platforms it would help a lot.