Skip to Content
Internet Protocol
Unreal Engine Plugin

UDP Server

UDP server for Unreal Engine: Blueprint nodes, events and C++ usage with the Internet Protocol plugin.

References

#include "udp/udpserver.h"

How to use

Blueprint: search by GetInternetProtocolSubsystem and call CreateUDPServer function

C++: Use the code bellow

#include "udp/udpserver.h"

UUDPServer* net = NewObject<UUDPServer>();

Datagrams in 4.0

  • The receive buffer is 64 KiB by default (16 KiB before). Datagrams that do not fit are dropped and counted instead of closing the socket.
  • When the Game Thread falls more than Max Pending Receive MB behind, new datagrams are dropped.
  • Windows ICMP "port unreachable" resets (WSAECONNRESET) no longer close the socket.

Nodes

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

Set Recv Buffer Size

  • Set receive buffer size in bytes
Set Recv Buffer SizeTarget is UDPServer
Target
Value
Function

Get Max Send Buffer Size

  • Get receive buffer size in bytes
Get Recv Buffer SizeTarget is UDPServer
Target
Return Value
Pure function

Send To

  • Broadcasts a string to an specific endpoint.
  • It returns false if socket is closed, if buffer is empty or if the send queue limit is exceeded.
Send ToTarget is UDPServer
Target
Message
Callback
Return Value
Function
On Message SentCustom Event
Error Code
Bytes Sent
Event

Send Buffer To

  • Broadcasts a buffer to an specific endpoint.
  • It returns false if socket is closed, if buffer is empty or if the send queue limit is exceeded.
Send Buffer ToTarget is UDPServer
Target
Buffer
Callback
Return Value
Function
On Message SentCustom Event
Error Code
Bytes Sent
Event

Bind

  • Listen for datagram messages on a named port and optional address.
  • It returns false if socket is already open or if asio return any error code during the bind.
  • Address must be an IP literal, localhost or empty (any address). Host names are not resolved: they, and ports outside 0-65535, fail with an Invalid argument error.
BindTarget is UDPServer
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 UDPServer
Target
Function

Broadcast and Multicast

New in 4.0. Errors of these nodes are reported through On Error.

Set Broadcast

  • Allows sending to broadcast addresses (for example 255.255.255.255 or 192.168.1.255).
Set BroadcastTarget is UDPServer
Target
Enable
Function

Join Multicast Group

  • Joins a multicast group, for example 239.0.0.1 or ff02::1. Returns false on error.
Join Multicast GroupTarget is UDPServer
Target
Group Address
Return Value
Function

Leave Multicast Group

  • Leaves a multicast group joined with Join Multicast Group.
Leave Multicast GroupTarget is UDPServer
Target
Group Address
Return Value
Function

Set Multicast TTL

  • Number of network hops multicast datagrams may cross (1 = local network only).
Set Multicast TTLTarget is UDPServer
Target
Hops
Function

Set Multicast Loopback

  • Whether this machine also receives the multicast datagrams it sends.
Set Multicast LoopbackTarget is UDPServer
Target
Enable
Function

Events

On Listening

  • This event will be triggered when socket start to listening.
Bind Event to On Listening
Target
Event
On ListeningCustom 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
Endpoint
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