Unreal Engine Plugin
TCP Server
TCP server for Unreal Engine: Blueprint nodes, events and C++ usage with the Internet Protocol plugin.
References
#include "tcp/tcpserver.h"
How to use
Blueprint: search by GetInternetProtocolSubsystem and call CreateTCPServer function
C++: Use the code bellow
#include "tcp/tcpserver.h"
UTCPServer* net = NewObject<UTCPServer>();Variables
Backlog
- Set/Get the maximum number of simultaneous client connections the server will accept in queue.
Backlog
Framing
- New in 4.0. How the TCP byte stream is cut into messages:
Raw(default),Length PrefixedorDelimiter. Both sides must use the same mode. See TCP Framing Options. - Applies to the next connection (client) or to accepted connections (server).
Framing
Use Tls
- New in 4.0. Encrypts the connection with TLS. With no
Set Tls Optionscall, the secure default options are used. - Applies to the next connection.
Use Tls
Nodes
Is Open
- Return true if socket is open.
Is Open
Return Value
Local Endpoint
- Get the local endpoint of the socket. Use this function only after open connection.
Local Endpoint
Return Value
Clients
- Returns a copy of the set of clients connected to the server (a reference before 4.0).
- A client stays in the set until its own
On Closearrives.
Clients
Return Value
Get Error Code
- Return a struct of the latest error code returned by asio.
Get Error Code
Return Value
Open
- Opens the TCP server and starts listening for incoming connections.
- It returns false if socket is already open or if asio return any error code during the bind.
Addressmust be an IP literal,localhostor empty (any address). Host names are not resolved: they, and ports outside 0-65535, fail with anInvalid argumenterror.
OpenTarget is TCPServer
Target
Bind Opts
Return Value
Close
- Close the underlying socket and stop listening for data on it. 'on_close' event will be triggered.
CloseTarget is TCPServer
Target
Set Tls Options
- New in 4.0. Turns TLS on with these options. See Security Context Options.
- A TLS server needs a certificate and a private key.
- Applies to the next connection.
Set Tls OptionsTarget is TCPServer
Target
Sec Opts
Events
On Listening
- This event will be triggered when socket start to listening.
Bind Event to On Listening
Target
Event
On ListeningCustom Event
On Client Accepted
- This event will be triggered when new client connect.
Bind Event to On Client Accepted
Target
Event
On Client AcceptedCustom Event
Client
On Close
- Event triggered when socket is closed.
Bind Event to On Close
Target
Event
On CloseCustom Event
On Error
- Event triggered if any error occur during async process.
Bind Event to On Error
Target
Event
On ErrorCustom Event
Error Code
Remote
Each client connected to the server is a TCP Remote (UTCPRemote), given by On Client Accepted and by Clients. In 4.0 the TLS server gives the same class: TCPRemoteSsl was merged into it.
Is Open
- Return true if the connection is open.
Is Open
Return Value
Local Endpoint
- Local endpoint of the connection.
Local Endpoint
Return Value
Remote Endpoint
- Address and port of the client.
Remote Endpoint
Return Value
Get Error Code
- Return a struct of the latest error code.
Get Error Code
Return Value
Get Stats
- New in 4.0. Traffic counters of the current connection: bytes and messages sent and received, and queued bytes. See Connection Stats.
Get Stats
Return Value
Write
- Sends string data to the client.
- It returns false if the connection is closed, if the buffer is empty or if the send queue limit is exceeded.
- With
Framingenabled, the framing is added automatically.
WriteTarget is TCPRemote
Target
Message
Callback
Return Value
Write Buffer
- Sends binary data to the client. Same rules as
Write.
Write BufferTarget is TCPRemote
Target
Buffer
Callback
Return Value
Close
- Closes the connection gracefully.
On Closewill be triggered.
CloseTarget is TCPRemote
Target
Remote Events
On Connected
- The connection is ready (for TLS servers, after the TLS handshake).
Bind Event to On Connected
Target
Event
On ConnectedCustom Event
On Message
- A message was received. With framing, one whole message per event.
Bind Event to On Message
Target
Event
On MessageCustom Event
Buffer
Bytes Recv
On Close
- The connection was closed. Fires exactly once.
Bind Event to On Close
Target
Event
On CloseCustom Event
On Error
- An error happened on this connection.
Bind Event to On Error
Target
Event
On ErrorCustom Event
Error Code