egametang/ET · critical · Exception
bind error: {ipEndPoint}
Error message
bind error: {ipEndPoint} What it means
IKcpTransport constructor binds a UDP socket to ipEndPoint and wraps any Bind failure. UDP bind can fail for the same reasons TCP can: port in use, address not assigned to a host, or insufficient privileges for low ports.
Source
Thrown at Packages/cn.etetet.core/Scripts/Core/Share/Network/IKcpTransport.cs:45
NetworkHelper.SetSioUdpConnReset(this.socket);
}
public UdpTransport(IPEndPoint ipEndPoint)
{
this.socket = new Socket(ipEndPoint.AddressFamily, SocketType.Dgram, ProtocolType.Udp);
if (!RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
{
this.socket.SendBufferSize = Kcp.OneM * 64;
this.socket.ReceiveBufferSize = Kcp.OneM * 64;
}
try
{
this.socket.Bind(ipEndPoint);
}
catch (Exception e)
{
throw new Exception($"bind error: {ipEndPoint}", e);
}
NetworkHelper.SetSioUdpConnReset(this.socket);
}
public void Send(byte[] bytes, int index, int length, EndPoint endPoint, ChannelType channelType)
{
this.socket.SendTo(bytes, index, length, SocketFlags.None, endPoint);
}
public int Recv(byte[] buffer, ref EndPoint endPoint)
{
return this.socket.ReceiveFrom(buffer, ref endPoint);
}
public IPEndPoint GetBindPoint()
{
return this.socket.LocalEndPoint as IPEndPoint;View on GitHub (pinned to 5cab01f7a8)
Solutions
- Free the port: stop the other process or let the OS release it (SO_REUSEADDR if your OS path allows).
- Bind to a local IP that exists (use IPAddress.Any or a confirmed interface address).
- Use an unprivileged port (>=1024) or run with elevated privileges.
- Read the wrapped inner SocketException for the exact socket error code.
Example fix
// before this.socket.Bind(ipEndPoint); // after var local = ipEndPoint.Address.Equals(IPAddress.Any) ? ipEndPoint : ipEndPoint; this.socket.Bind(local); // ensure local.Address is assigned to this host
Defensive patterns
Strategy: try-catch
Validate before calling
static bool IsPortFreeUDP(IPEndPoint ep)
{
try { using var s = new Socket(ep.AddressFamily, SocketType.Dgram, ProtocolType.Udp); s.Bind(ep); return true; }
catch { return false; }
} Type guard
null
Try / catch
try { transport = new KcpTransport(ipEndPoint); }
catch (Exception e) when (e.Message.StartsWith("bind error"))
{ Log.Error($"udp bind failed for {ipEndPoint}: {e.InnerException?.Message}"); throw; } Prevention
- Probe the port before binding at startup.
- Run only one instance per configured UDP port.
- Use local interface addresses you have verified exist.
When it happens
Trigger: Two services binding the same UDP port, binding to an IP not present on the machine, or binding a port <1024 as non-root on Linux.
Common situations: Process restarted while the old socket is still in TIME_WAIT / held, misconfigured outer IP, or another instance already running.
Related errors
- kchannel connected but kcp is zero!
- GetChannelConn conn not found KChannel! {channelId}
- socket set buffer error: {this.sendBuffer.First.Length}, {th
- bind error: {ipEndPoint}
- socket error: {e.LastOperation}
AI-assisted analysis of egametang/ET@5cab01f7a8 (2026-08-13).
Data as JSON: /api/errors/629b09ca25724fc7.
Report an issue: GitHub.