private void BeginSend() { if (_Running == 0) { return; } RawData raw; if (!_SendingQueue.TryDequeue(out raw)) { System.Threading.Interlocked.Exchange(ref _Writing, 0); return; } UDPSocket socket = _Socket; IPEndPoint remoteEP = (IPEndPoint)raw.EndPoint; if (remoteEP.AddressFamily == AddressFamily.InterNetwork) { if (_SocketIPv4 != null) { // use the separated socket of IPv4 to deal with IPv4 conversions. socket = _SocketIPv4; } else if (_Socket.Socket.AddressFamily == AddressFamily.InterNetworkV6) { remoteEP = new IPEndPoint(IPAddressExtensions.MapToIPv6(remoteEP.Address), remoteEP.Port); } } BeginSend(socket, raw.Data, remoteEP); }
public void Send(byte[] data, System.Net.EndPoint ep) { Server socket = _Server; IPEndPoint remoteEP = (IPEndPoint)ep; if (remoteEP.AddressFamily == AddressFamily.InterNetwork) { if (_ServerIPv4 != null) { // use the separated socket of IPv4 to deal with IPv4 conversions. socket = _ServerIPv4; } else if (_Server.LocalEndPoint.AddressFamily == AddressFamily.InterNetworkV6) { remoteEP = new IPEndPoint(IPAddressExtensions.MapToIPv6(remoteEP.Address), remoteEP.Port); } } socket.Send(remoteEP, data); }
public void Send(byte[] data, System.Net.EndPoint ep) { DTLS.Client socket = _Client; IPEndPoint remoteEP = (IPEndPoint)ep; if (remoteEP.AddressFamily == AddressFamily.InterNetwork) { if (_ClientIPv4 != null) { // use the separated socket of IPv4 to deal with IPv4 conversions. socket = _ClientIPv4; } else if (_Client.LocalEndPoint.AddressFamily == AddressFamily.InterNetworkV6) { remoteEP = new IPEndPoint(IPAddressExtensions.MapToIPv6(remoteEP.Address), remoteEP.Port); } } if (!_Connected) { socket.ConnectToServer(remoteEP); _Connected = true; } socket.Send(data); }