Skip to Content
Internet Protocol
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 Prefixed or Delimiter. Both sides must use the same mode. See TCP Framing Options.
  • Applies to the next connection (client) or to accepted connections (server).
Framing
Variable

Use Tls

  • New in 4.0. Encrypts the connection with TLS. With no Set Tls Options call, the secure default options are used.
  • Applies to the next connection.
Use Tls
Variable

Functions

Is Open

  • Return true if socket is open.
Is Open
Return Value
Pure function

Local Endpoint

  • Get the local endpoint of the socket. Use this function only after open connection.
Local Endpoint
Return Value
Pure function

Remote Endpoint

  • Get the remote endpoint of the socket. Use this function only after open connection.
Remote Endpoint
Return Value
Pure function

Get Error Code

  • Return a struct of the latest error code returned by asio.
Get Error Code
Return Value
Pure function

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 Framing enabled, the length prefix or the delimiter is added automatically. A message larger than Max Message Bytes fails with Message too large.
WriteTarget is TCPClient
Target
Message
Callback
Return Value
Function
On Message SentCustom Event
Error Code
Bytes Sent
Event

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 Framing enabled, the length prefix or the delimiter is added automatically. A message larger than Max Message Bytes fails with Message too large.
Write BufferTarget is TCPClient
Target
Buffer
Callback
Return Value
Function
On Message SentCustom Event
Error Code
Bytes Sent
Event

Connect

  • Resolve the address and connect asynchronously. On Connected is triggered when the connection is established, On Error if 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 with Protocol = Any every resolved IPv4 and IPv6 address is tried. See Client Bind Options.
ConnectTarget is TCPClient
Target
Bind Opts
Return Value
Function

Close

  • Close the underlying socket and stop listening for data on it. 'on_close' event will be triggered.
CloseTarget is TCPClient
Target
Function

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
Pure function

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
Function

Events

On Connected

  • Event triggered when a connection is estabilished.
Bind Event to On Connected
Target
Event
On ConnectedCustom Event
Event binding

On Message

  • Event triggered when socket send or receive data.
Bind Event to On Message
Target
Event
On MessageCustom Event
Buffer
Bytes Recvd
Event binding

On Close

  • Event triggered when socket is closed.
Bind Event to On Close
Target
Event
On CloseCustom Event
Event binding

On Error

  • Event triggered if any error occur during async process.
Bind Event to On Error
Target
Event
On ErrorCustom Event
Error Code
Event binding
Edit on GitHub

On this page