Sending data from UE4 to server via TCP - strange 'burst mode' behavior

I am trying to get data out of UE4 and send it across a local network to another application that I have running on a server. To aid with this, I wrote a C++/C# networking library that I have been using successfully in other applications that I wrote. The server-side app is written in C#, and client side apps can be either C++ or C#. I am using Windows 7 on both client and server.

To test the integration into UE4, I modified the landscapes demo to send out data using this networking library every time the ‘Event Tick’ occurs. Although the expected data shows up on the server side application, data is received in bursts only. Bursts happen about once per second, and in the remaining time no data is being received. I need this data stream to be continuous, given what I am working on (hooking up UE4 / Oculus Rift to a machine that can spin people around in multiple axes)

To rule out that the burst-transmission behavior is related to the C++ library code, I wrote a small standalone C++ test app that sends out data as fast as possible. When I run this test app, data is being received at the server-side continuously, as you would expect. Note that I am setting the TCP_NODELAY socket option on client side, to disable the Nagle algorithm.

Based on this behavior, I wonder if UE4 is ‘doing something under the hood’ that affects how sockets are being handled / how data is being sent. But I am clueless as to what this could be. Is there anything that I am missing here? Would it make more sense to use FTcpSocketBuilder in the client side code (I just found out about that a few minutes ago, but thought I’d ask here before spending the time to rewrite part of the library I use)?

Thanks for reading, and thanks in advance for any help/advise!

This is unusual behavior that I have not seen before. We are not doing anything special in our socket code, however. FTcpSocketBuilder is just a convenience class for creating sockets. It uses the same socket implementation under the hood.

Can you post some of your socket creation code?
Also, did you verify that Tick is being called as expected?

Thank you for your feedback so far!

Below you will find some relevant code. However I have verified that the code works, by creating a standalone c++ app that uses the same code to send out data to the server. The dataflow is constant, and does not show the ‘burst’ link textbehavior as I see when using the code with UE4.

I did have an idea about where the problem could be: the way that I wrote the socket handling code is that there is a worker thread which constantly checks if there is any data to send, and if so, sends it. I do not use any UE4 thread management/creation code (just as I do not use any UE4 socket creation/management). I was wondering if that is the cause of the ‘burst’ behavior- that UE4 suspends all threads that are not managed/created with the UE4 thread handling code. Any thoughts?

Attached is the relevant (pseudo) code. It uses code (A Universal TCP Socket Class for Non-blocking Server/Clients - CodeProject) which handles creation/management of non-blocking sockets. All relevant code runs in a separate worker thread.

Sorry, this code is completely outside of UE4, and I’m afraid I can’t help you with that. Try to implement the feature using the UE4 socket sub-system and threading, and check back if the problem persists.