Unreal Engine Plugin
TCP Client
TCP client for Unreal Engine: Blueprint nodes, events and C++ usage with the Internet Protocol plugin.
References
#include "tcp/tcpclient.h"
How to use
Blueprint: search by GetInternetProtocolSubsystem and call CreateTCPClient function
C++: Use the code bellow
#include "tcp/tcpclient.h"
UTCPClient* client = NewObject<UTCPClient>();Variables
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
Functions
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
Remote Endpoint
- Get the remote endpoint of the socket. Use this function only after open connection.
Remote Endpoint
Return Value
Get Error Code
- Return a struct of the latest error code returned by asio.
Get Error Code
Return Value
Write
- Sends string data on the socket.
- It returns false if socket is closed, if buffer is empty or if the send queue limit is exceeded.
- With
Framingenabled, the length prefix or the delimiter is added automatically. A message larger thanMax Message Bytesfails withMessage too large.
WriteTarget is TCPClient
Target
Message
Callback
Return Value
On Message SentCustom Event
Error Code
Bytes Sent
Write Buffer
- Sends buffer data on the socket.
- It returns false if socket is closed, if buffer is empty or if the send queue limit is exceeded.
- With
Framingenabled, the length prefix or the delimiter is added automatically. A message larger thanMax Message Bytesfails withMessage too large.
Write BufferTarget is TCPClient
Target
Buffer
Callback
Return Value
On Message SentCustom Event
Error Code
Bytes Sent
Connect
- Resolve the address and connect asynchronously.
On Connectedis triggered when the connection is established,On Errorif it fails. - It returns false if the socket is already open or connecting.
- Since 4.0 the connection must complete within
Connect Timeout Seconds(15 s by default), and withProtocol = Anyevery resolved IPv4 and IPv6 address is tried. See Client Bind Options.
ConnectTarget is TCPClient
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 TCPClient
Target
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
Set Tls Options
- New in 4.0. Turns TLS on with these options. See Security Context Options.
- The server certificate is verified with these options.
- Applies to the next connection.
Set Tls OptionsTarget is TCPClient
Target
Sec Opts
Events
On Connected
- Event triggered when a connection is estabilished.
Bind Event to On Connected
Target
Event
On ConnectedCustom Event
On Message
- Event triggered when socket send or receive data.
Bind Event to On Message
Target
Event
On MessageCustom Event
Buffer
Bytes Recvd
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