Skip to content
Back
This page's table of contents

User guide

SimpleUDP User Guide

Complete product user guide for SimpleUDP

SimpleUDP is a lightweight UDP communication plugin for Unreal Engine.
It supports runtime dynamic configuration of send/receive channels, and all functionality is exposed to Blueprint for easy integration.

  • Unreal Engine 5.2–5.8
  • Version 1.1.0 (Version 2)

The plugin takes effect immediately after enabling.
It registers internally as a GameInstanceSubsystem — no manual startup or shutdown code required.


⚙️ Static Channel Configuration (Optional)

Section titled “⚙️ Static Channel Configuration (Optional)”

You can pre-configure channels via Project Settings → SimpleUDP Settings.

Note: While runtime channel modification is supported, it’s recommended to configure channels here whenever possible for better manageability.

FieldExampleDescription
Channel NameDefaultRecvChannel name used in Blueprint
Bind Address0.0.0.0:9000Local IP and port to listen on
Max Receive Bytes1024Max packet size per receive
Filter ModeNone / Whitelist / BlacklistIP filtering mode
Whitelist / Blacklist["192.168.1.0/24"]Supports CIDR format

Important: Max Receive Bytes defaults to 1024 bytes. If a single UDP datagram in your protocol may exceed 1024 bytes, increase this value in the receive channel configuration before receiving; otherwise, the datagram may not be received completely.

FieldExampleDescription
Channel NameDefaultSendChannel name
Target Addresses["255.255.255.255:9000"]List of destination IP:Port
Fixed Port 🔧0 (default)Local bind port for sending socket (0 = auto)
Max Send Bytes1024Max size per packet

Important: Max Send Bytes defaults to 1024 bytes. If a single UDP datagram in your protocol may exceed 1024 bytes, increase this value in the send channel configuration before sending; otherwise, only data up to the configured limit will be sent.


NodeDescription
BindUDPMessageHandlerBind a message receive callback
UnBindUDPMessageHandlerUnbind a specific handler
UnBindAllUDPMessageHandlerUnbind all handlers and close socket
NodeDescription
SendUDPMessageSend a byte array through the channel (socket auto-created)
NodeDescription
UpdateReceiveChannelConfigCreate/update a receive channel (rebinding if needed)
UpdateSendChannelConfigCreate/update a send channel, supports FixedPort ✅
GetReceiveChannelConfigGet one receive channel config
GetSendChannelConfigGet one send channel config
GetAllReceiveChannelConfigGet all receive channel configs
GetAllSendChannelConfigGet all send channel configs
NodeDescription
ParseEndpointParse "127.0.0.1:9000" to IP and port
IsIPInCIDRCheck if an IP is in a CIDR block

TypeCreated WhenDestroyed When
ReceiverFirst call to BindUDPMessageHandlerAll handlers removed → auto close socket
SenderFirst call to SendUDPMessage or configPlugin shutdown or channel deleted

ShowAllFuntion

StartReceiveMessage

Socket is created automatically after the first bind, and destroyed when no more handlers remain.

StopReceiveMessage

Use this node to unbind everything from a channel and close the socket manually.

DynamicAddOrUpdateReceiveChannelConfig

Socket is auto-rebuilt if needed. Function order doesn’t matter.

The two booleans control whether to override existing channels or add new ones.

DynamicUpdateSendChnnelConfig

Send sockets only rebuild if FixedPort is different.

The two booleans behave the same as receive config.

SendMessage


  • Only IPv4 is supported (no IPv6 or domain resolution)
  • Valid port range: 0~65535, where 0 means auto-assign
  • Do not bind the same port in different channels unless the socket is released
  • IP filters support CIDR format (e.g. 192.168.1.0/24)

Use with SimpleByteConversion plugin to easily serialize/deserialize between data ↔ TArray<uint8>.


Native UDP sockets and use cases

1.1 Use cases

  • Collecting sensor data, such as LiDAR, camera, and GPS data
  • Connecting simulators such as CarSim and PreScan
  • LAN broadcast or multicast
  • Real-time control commands

1.2 Basic implementation

Create a UDP socket and bind a port:

#include "Sockets.h"
#include "SocketSubsystem.h"
// 获取Socket子系统
ISocketSubsystem* SocketSubsystem = ISocketSubsystem::Get(PLATFORM_SOCKETSUBSYSTEM);
// 创建UDP Socket
FSocket* RecvSocket = SocketSubsystem->CreateSocket(NAME_DGram, TEXT("UDP Receiver"), false);
// 创建地址并绑定
TSharedRef<FInternetAddr> Addr = SocketSubsystem->CreateInternetAddr();
Addr->SetPort(8888);
Addr->SetAnyAddress();
if (RecvSocket->Bind(*Addr))
{
UE_LOG(LogTemp, Log, TEXT("UDP Socket绑定成功,端口: 8888"));
}
// 设置非阻塞模式
RecvSocket->SetNonBlocking(true);

Receive UDP data:

void ReceiveUDPData(FSocket* RecvSocket)
{
ISocketSubsystem* SocketSubsystem = ISocketSubsystem::Get(PLATFORM_SOCKETSUBSYSTEM);
TArray<uint8> RecvData;
RecvData.SetNumUninitialized(65507); // UDP最大包大小
int32 BytesRead = 0;
TSharedRef<FInternetAddr> SenderAddr = SocketSubsystem->CreateInternetAddr();
if (RecvSocket->RecvFrom(RecvData.GetData(), RecvData.Num(), BytesRead, *SenderAddr))
{
RecvData.SetNum(BytesRead);
FString SenderIP = SenderAddr->ToString(false);
int32 SenderPort = SenderAddr->GetPort();
UE_LOG(LogTemp, Log, TEXT("收到来自 %s:%d 的数据,大小: %d"),
*SenderIP, SenderPort, BytesRead);
// 处理接收到的数据
ProcessReceivedData(RecvData);
}
}

Send UDP data:

void SendUDPData(const FString& TargetIP, int32 TargetPort, const TArray<uint8>& Data)
{
ISocketSubsystem* SocketSubsystem = ISocketSubsystem::Get(PLATFORM_SOCKETSUBSYSTEM);
FSocket* SendSocket = SocketSubsystem->CreateSocket(NAME_DGram, TEXT("UDP Sender"), false);
TSharedRef<FInternetAddr> RemoteAddr = SocketSubsystem->CreateInternetAddr();
bool bIsValid;
RemoteAddr->SetIp(*TargetIP, bIsValid);
RemoteAddr->SetPort(TargetPort);
if (bIsValid)
{
int32 BytesSent = 0;
SendSocket->SendTo(Data.GetData(), Data.Num(), BytesSent, *RemoteAddr);
UE_LOG(LogTemp, Log, TEXT("发送 %d 字节到 %s:%d"), BytesSent, *TargetIP, TargetPort);
}
SendSocket->Close();
ISocketSubsystem::Get()->DestroySocket(SendSocket);
}

Native examples and plugin channels

These three FSocket examples demonstrate binding, receiving, and sending. They are not SimpleUDP Blueprint APIs. Implement ProcessReceivedData in your project. Check object validity and the return values from creation, binding, data transfer, and closing. The receiver also needs an explicit exit and cleanup path. A nonblocking native socket does not by itself provide a background receive thread.

The example’s 65507 illustrates the usual IPv4 UDP datagram payload limit. It is not a recommended packet size. The usable size also depends on path MTU, fragmentation, and plugin channel buffers. Broadcast and multicast are protocol use cases; listing them does not mean the plugin has configured the routes, socket options, or subscriptions they require. UDP does not guarantee delivery or ordering, so application logic must handle packet loss and message identity.

See the TCP client and network communication guide for protocol choices, threading, and data conversion.

The native communication examples were published on Cnblogs on 2025-10-25.

Open Edit → Project Settings, select the SimpleUDP settings page, and set Language to English or Chinese. English is the default. Available user-facing UI, tooltips, notifications, and functional logs update immediately without restarting the editor. Public API names and module startup/shutdown logs remain in English.

For usage questions or collaboration, please visit the contact page.