public void Connect(IpEndpoint ipEndpoint) { _ipEndpoint = Converter.Convert(ipEndpoint); _socket.Connect(_ipEndpoint); #pragma warning disable 618 var socketLocalEndPoint = (IPEndPoint)_socket.LocalEndPoint; LocalIpEndpoint = new IpEndpoint(new IpAddress((uint)socketLocalEndPoint.Address.Address), socketLocalEndPoint.Port); #pragma warning restore 618 }
public UdpListener(IpEndpoint ipEndPoint) { _socket = SocketFactory.Create(); _socket.Bind(new IPEndPoint(ipEndPoint.IpAddress.Ipv4Address, ipEndPoint.Port)); _anyEndPoint = new IPEndPoint(IPAddress.Any, 0); #pragma warning disable 618 var socketLocalEndPoint = (IPEndPoint)_socket.LocalEndPoint; LocalIpEndpoint = new IpEndpoint(new IpAddress((uint)socketLocalEndPoint.Address.Address), socketLocalEndPoint.Port); #pragma warning restore 618 }
public int Receive(byte[] buffer, int offset, int count, out IpEndpoint ipEndpoint) { EndPoint endpoint = _anyEndPoint; int read; try { read = _socket.ReceiveFrom(buffer, offset, count, SocketFlags.None, ref endpoint); } catch (SocketException socketException) { // TODO: consider exceptions for bugs only // TODO: this fails when remote is closed?!? throw new UdpSocketException(socketException.Message, socketException.ErrorCode); } var ipEndPoint2 = ((IPEndPoint)endpoint); #pragma warning disable 618 ipEndpoint = new IpEndpoint(new IpAddress((uint)ipEndPoint2.Address.Address), ipEndPoint2.Port); #pragma warning restore 618 return(read); }
public void Connect(IpEndpoint ipEndpoint) { BaitAndSwitch.Throw(); }
public UdpClient() { LocalIpEndpoint = new IpEndpoint(IpAddress.AnyAddress, 0); BaitAndSwitch.Throw(); }
public static IPEndPoint Convert(IpEndpoint ipEndpoint) { return(new IPEndPoint(ipEndpoint.IpAddress.Ipv4Address, ipEndpoint.Port)); }
public UdpSend(Socket socket, IpEndpoint ipEndPoint) { _socket = socket; _ipEndPoint = Converter.Convert(ipEndPoint); }
public IUdpSend ForkSendTo(IpEndpoint ipEndPoint) { return(new UdpSend(_socket, ipEndPoint)); }