Documentation updated on 01/09/2023
Contact(ENG,GER): unrealmarketplace@virtualbird.de

Plugin is located, after the installation via the launcher, in the directory: Engine\Plugins\Marketplace
If you use the UE4 GIT version you have to copy the plugin into your project: D:\myproject\Plugins\SocketServer

For older versions of this plugin some functions might be missing or look different. I follow the marketplace rules and release updates and patches only for the latest 3 UE4 versions.
To have the documentation always available you can use the print function of your browser and create a PDF.

Start your project and check plugins.





You can optionally change the global type of the socket. Default is "Auto".
Auto = UE4 decides. Thirdparty platforms (Steam, Playstore etc.) will be used if configured.
System = UE4 determines the OS and selects a socket type accordingly.




In this example you will see how to add an event.



The following examples can be found in the level blueprint of the map "ServerSocketDemoSimpleExamples" in the demo project. Don't hesitate to send an e-mail if you have any questions.

UDP Example





TCP Example






It can happen that large messages are split at the receiver. Or that messages, which are sent very quickly, are combined into one. To work around the problem there is the parameter "Message Separator" with three options.

Via one Byte A byte is appended after each message. Default value is the byte 0 (0x00).
Via String A String is appended after each message. Default value is (~{.
By Lenght When this setting is selected, 5 bytes are added in front of each dataset. The first byte indicates the endianness. (0x00 = Little, 0x01 = Big). The other 4 bytes are an int32 with the length of the record.

Keep in mind that the client and server settings must match.


The separator can be changed. Must be changed before the server is started.











This plugin offers the following file/directory functions. Please make sure that not all functions work on all operating systems due to rights restrictions.




Since version 1.30 (UE4.25 and higher) there are special functions to transfer files without loading them into RAM. This allows theoretically to send infinitely large files.
For owners of the client and server plugin it will be especially comfortable. The functions provided for this communicate with each other before the file transfer and afterwards.
This allows a progress indicator, resuming of aborted transfers and there is a MD5 checksum check at the end to make sure that the file arrived undamaged.
The communication is encrypted with AES. The transfer is unencrypted.

Please note the tooltips of the function and the parameters.

For file transfer there is a separate function to start the server. The old TCP events are also triggered on the file server.




In order for the server to receive a file from the client or to send a file, a token must be created beforehand.
This prevents information about the file structure of the server to be revealed to the client and you can create temporary tokens and send them only to certain clients.
In this example, the token "MyTokenForFileUploads" is created to specify the directory where the files from the clients end up and a token with a file that the client can grab.
Tokens do not have to be readable text. It can also be something like "GKaPdSg". Tokens can be created via a web server or via other connections. They can be deleted automatically after the data transfer.
When transferring data over the Internet, it is important to make it as difficult as possible for unauthorized clients to upload or download files.




There are two events. The first event is triggered when there is an error during the transfer and at the end of the transfer. The second event is fired every second during a transfer and shows the progress.




If you have only bought the server plugin, you can also read files step by step without having to load them completely into RAM. However, the communication must be created completely by yourself.
When sending a file you have to call the function "Read Bytes from File in Parts Async".

The buffer indicates the size in bytes that will be read from the file. The delay specifies how long to wait until the next part is read.
This is necessary so that reading is not too fast. With an SSD you can read several gigabytes per second.
But you can't send the data that fast. If you read too fast, the data would be buffered in some buffer (RAM) in the OS, which could lead to problems again. Just try different values if the data is read too slowly.




Since the data is read asynchronously there is an event that returns the read bytes. These bytes can be sent.




If you want to receive bytes to save them to a file you have to open a file first. When you open the file, it is automatically created and returned as a structure.
In this example a file is opened when the connection is established and closed when the connection is closed.




Write bytes from a TCP connection to an open file.




Since version 1.30 (UE4.25 and higher) you can encrypt and decrypt strings with AES 256 bit.
The encrypted string is returned as a Base64 string and accordingly a string must be Base64 to be decrypted again. The key must be 32 characters long and only ASCII characters may be used. There are AES key generators on the Internet that you can use.




Since version 1.40 (UE4.26 and higher) you can run a RCON server. Many games (Minecraft, CS:GO, Rust) use the RCON protocol to control the game servers.
Therefore there are different third party clients. These clients can connect to your Unreal server via this plugin and execute commands. You have to define the commands yourself.
Start a TCP server and register a RCON server on it.
You can choose the password type between a string parameter and a game or global directory to a file. If you choose the string, you just have to enter the password as a parameter.
Otherwise enter the directory to a file like for example: "Content\RCON\password.txt" with the type (game directory). The file will be created if it does not exist.


Then you need to add the event "onReceiveRCONRequest". All requests from the clients will end up there. All requests must be answered otherwise the client might get stuck.
You can send a response to the client with the function "Send Rcon Response". If there is no data to reply then just send back a blank reply.
In this example there are two commands. "help" and "con". The con command triggers Unreal console commands like "stat fps".



Since version 1.50 (UE4.27 and higher) there is an additional thread running in the plugin that deletes disconnected connections from RAM. Here you can set whether the thread should write its work in the logs and how often it runs.




Nativization

This plugin is designed for extensive multithreading. Multithreading means that the CPU load is spread across all CPU cores so as not to affect the FPS while data is being sent and received.
Unfortunately, this leads to incopatibilty with Blueprint Nativization. Please use the Exclusive method and use the plugin only in Blueprints that are not nativized.
According to the current information, nativization will no longer exist in UE5 anyway.

Contact(ENG,GER): unrealmarketplace@virtualbird.de