Using a winsock socket causes my unreal editor to freeze when pressing play

Hello, i am relatively new to Unreal Engine. However, i am trying to create a game which is controlled by a stroke rehabilitation robot for the purpose of stroke rehabilitation. I created a winsock socket to send the output of the robot to the unreal code so i could control a pawn/actor in the game by using the robot. I set up the socket with the unreal code being the client and the robots code being the server. The issue is when i press play on unreal the unreal editor screen freezes but the output is still being sent and the winsock socket is connecting.

I was wondering if anybody had experienced this problem before? And if anybody has any suggestions on how i could fix this or what is going wrong?

Any help would be appreciated. Thanks.

it would help if we could see the relevant code?

1 Like

Also could you not just use the websocket module in the engine? It uses the delegate system to send and receive messages so it’s fairly async.

@Rumzie Thanks for your reply. Ill have a look into this as i didn’t know there was already a module like that in unreal. Thanks.

You’ll have to include the proper modules in your build.cs or you’ll get linker errors when trying to #include paths from the websocket module.

The websocket module’s on message received has to option to return the value as raw blobs if that suits you better, but strings are the other option.

There are also unreal sockets that are a couple levels lower, but I’ve never fudged with them.

The main issue I see with your system is that it’s inherently going to be running on the game thread, which is a nono. If you still want to use winsock I would try doing it in a subsystem. They are lifetime handled singleton that live and die with the life of the engine. Programming Subsystems | Unreal Engine 4.27 Documentation

Then you could use the delegate system to handle requests async to start at worse, and at best implement your own async network logic however you prefer decoupled from the game thread.

1 Like