public override int SendTo(byte[] buffer, int bytesToSend, UdpEndPoint endpoint) { try { return socket.SendTo(buffer, 0, bytesToSend, SocketFlags.None, DotNetPlatform.ConvertEndPoint(endpoint)); } catch (SocketException exn) { HandleSocketException(exn); return -1; } }
public override void Bind(UdpEndPoint ep) { try { error = null; socket.Bind(DotNetPlatform.ConvertEndPoint(ep)); endpoint = DotNetPlatform.ConvertEndPoint(socket.LocalEndPoint); UdpLog.Info("Socket bound to {0}", endpoint); } catch (SocketException exn) { HandleSocketException(exn); } }
public override int RecvFrom(byte[] buffer, int bufferSize, ref UdpEndPoint endpoint) { try { int bytesReceived = socket.ReceiveFrom(buffer, 0, bufferSize, SocketFlags.None, ref recvEndPoint); if (bytesReceived > 0) { endpoint = DotNetPlatform.ConvertEndPoint(recvEndPoint); return bytesReceived; } else { return -1; } } catch (SocketException exn) { HandleSocketException(exn); return -1; } }
public override void Bind(UdpEndPoint ep) { try { this.error = null; this.socket.Bind(DotNetPlatform.ConvertEndPoint(ep)); this.endpoint = DotNetPlatform.ConvertEndPoint(this.socket.LocalEndPoint); UdpLog.Info("Socket bound to {0}", new object[] { this.endpoint }); } catch (SocketException exn) { this.HandleSocketException(exn); } }
public override int RecvFrom(byte[] buffer, int bufferSize, ref UdpEndPoint endpoint) { int result; try { int num = this.socket.ReceiveFrom(buffer, 0, bufferSize, SocketFlags.None, ref this.recvEndPoint); if (num > 0) { endpoint = DotNetPlatform.ConvertEndPoint(this.recvEndPoint); result = num; } else { result = -1; } } catch (SocketException exn) { this.HandleSocketException(exn); result = -1; } return(result); }
public static UdpEndPoint ConvertEndPoint(EndPoint endpoint) { return(DotNetPlatform.ConvertEndPoint((IPEndPoint)endpoint)); }