/// <summary> /// Create a new socket for an address and port /// </summary> /// <param name="address">The ip address of the local or remote end point</param> /// <param name="port">the port, use 0 for dynamically assigned (receiver only)</param> internal OscSocket(IPAddress address, int port) { if (address.AddressFamily != AddressFamily.InterNetwork && address.AddressFamily != AddressFamily.InterNetworkV6) { throw new ArgumentException(String.Format(Strings.Socket_UnsupportedAddressFamily, address.AddressFamily), "address"); } m_UseIpV6 = address.AddressFamily == AddressFamily.InterNetworkV6; CheckPortRange(port, "port", Strings.Socket_PortOutOfRange, this.OscSocketType == Osc.OscSocketType.Receive); m_Port = port; m_LocalPort = port; m_UseDynamicLocalPort = port == 0; if (this.OscSocketType == Osc.OscSocketType.Send) { m_LocalAddress = m_UseIpV6 ? IPAddress.IPv6Any : IPAddress.Any; m_RemoteAddress = address; } else { m_LocalAddress = address; m_RemoteAddress = m_UseIpV6 ? IPAddress.IPv6Any : IPAddress.Any; } m_LocalEndPoint = new IPEndPoint(LocalAddress, Port); m_RemoteEndPoint = new IPEndPoint(RemoteAddress, Port); m_IsMulticastEndPoint = IsMulticastAddress(m_RemoteAddress); m_SocketFlags = System.Net.Sockets.SocketFlags.None; }
public int Receive(byte[] buffer, System.Net.Sockets.SocketFlags socketFlags) { #if SECURE_BLACKBOX_DEBUG LowLevelDump("ElSSLSocket.Receive() {}"); #endif return(Receive(buffer)); }
public int Receive(byte[] buffer, int offset, int size, System.Net.Sockets.SocketFlags socketFlags) { #if SECURE_BLACKBOX_DEBUG LowLevelDump("ElSSLSocket.Receive() {}"); #endif byte[] buf = new byte[size]; int result = Receive(buf); Array.Copy(buf, 0, buffer, offset, result); return(result); }
public int Send(byte[] InBytes, System.Net.Sockets.SocketFlags InFlag) { int Lx; if (mSecureSocket != null) { Lx = mSecureSocket.Send(InBytes, InBytes.Length, InFlag); } else { Lx = mSocket.Send(InBytes, InBytes.Length, InFlag); } return(Lx); }
Sockets.SocketError Send(byte[] buffer, int offset, int size, Sockets.SocketFlags socketFlags = Sockets.SocketFlags.None) { Sockets.SocketError result = Sockets.SocketError.Success; int bytesSent = 0; while (bytesSent < size && result == Sockets.SocketError.Success) { bytesSent += socket.Send(buffer, offset + bytesSent, size - bytesSent, socketFlags, out result); } if (result == Sockets.SocketError.Success && bytesSent < size) { throw new System.IO.IOException("Сообщение отправлено не полностью"); } return(result); }
/// <summary> /// Create a new socket for an address and port /// </summary> /// <param name="local">The ip address of the local end point</param> /// <param name="localPort">the local port, use 0 for dynamically assigned</param> /// <param name="remote">The ip address of the remote end point</param> /// <param name="remotePort">the remote port</param> /// <param name="timeToLive">TTL value to apply to packets</param> internal OscSocket(IPAddress local, int localPort, IPAddress remote, int remotePort, int timeToLive) { if (local.AddressFamily != AddressFamily.InterNetwork && local.AddressFamily != AddressFamily.InterNetworkV6) { throw new ArgumentException(String.Format(Strings.Socket_UnsupportedAddressFamily, local.AddressFamily), "local"); } if (remote.AddressFamily != AddressFamily.InterNetwork && remote.AddressFamily != AddressFamily.InterNetworkV6) { throw new ArgumentException(String.Format(Strings.Socket_UnsupportedAddressFamily, local.AddressFamily), "remote"); } if (local.AddressFamily != remote.AddressFamily) { throw new Exception(Strings.Socket_AddressFamilyIncompatible); } CheckPortRange(remotePort, "remotePort", Strings.Socket_RemotePortOutOfRange, false); CheckPortRange(localPort, "localPort", Strings.Socket_LocalPortOutOfRange, true); // if the local port is 0 then we are to use dynamic port assignment m_UseDynamicLocalPort = localPort == 0; m_LocalAddress = local; m_RemoteAddress = remote; m_Port = remotePort; m_LocalPort = localPort; m_RemoteEndPoint = new IPEndPoint(RemoteAddress, remotePort); m_LocalEndPoint = new IPEndPoint(LocalAddress, localPort); m_TimeToLive = timeToLive; m_UseIpV6 = m_LocalAddress.AddressFamily == AddressFamily.InterNetworkV6; m_IsMulticastEndPoint = IsMulticastAddress(m_RemoteAddress); m_SocketFlags = System.Net.Sockets.SocketFlags.None; }
/// <summary> /// Create a new socket for any local IP address and a port /// </summary> /// <param name="port">the port to bind to, use 0 for dynamically assigned (receiver only)</param> internal OscSocket(int port) { CheckPortRange(port, "port", Strings.Socket_PortOutOfRange, this.OscSocketType == Osc.OscSocketType.Receive); m_Port = port; m_LocalPort = port; m_UseDynamicLocalPort = port == 0; m_LocalAddress = IPAddress.Any; m_RemoteAddress = IPAddress.Any; m_LocalEndPoint = new IPEndPoint(LocalAddress, Port); m_RemoteEndPoint = new IPEndPoint(RemoteAddress, Port); m_SocketFlags = System.Net.Sockets.SocketFlags.None; m_UseIpV6 = false; m_IsMulticastEndPoint = false; }
unsafe public override int Receive(byte [] buffer, int offset, int size, sock.SocketFlags flags) { if (!connected) { return(0); } int value; fixed(byte *ptr = buffer) value = recv(socket, ptr + offset, size, (int)flags); if (value >= 0) { return(value); } connected = false; throw GetException(); }
unsafe public override int Send(byte [] data, int offset, int size, sock.SocketFlags flags) { if (!connected) { return(0); } int value; fixed(byte *ptr = data) value = send(socket, ptr + offset, size, (int)flags); if (value >= 0) { return(value); } connected = false; throw GetException(); }
// TODO: Correct ??? public static IAsyncResult BeginReceiveFrom(this System.Net.Sockets.Socket socket , byte[] buffer, int offset, int size, System.Net.Sockets.SocketFlags socketFlags, ref System.Net.EndPoint remoteEP , AsyncCallback callback, object state) { ArraySegment <byte> buffer2 = buffer.ToArraySegment(offset, size); return(socket.ReceiveFromAsync(buffer2, socketFlags, remoteEP).AsApm(callback, state)); }
public static System.Threading.Tasks.Task <int> SendToAsync(this System.Net.Sockets.Socket socket, System.ArraySegment <byte> buffer, System.Net.Sockets.SocketFlags socketFlags, System.Net.EndPoint remoteEndPoint) { throw null; }
public static System.Threading.Tasks.Task <int> SendAsync(this System.Net.Sockets.Socket socket, System.Collections.Generic.IList <System.ArraySegment <byte> > buffers, System.Net.Sockets.SocketFlags socketFlags) { throw null; }
public static System.Threading.Tasks.Task <System.Net.Sockets.SocketReceiveMessageFromResult> ReceiveMessageFromAsync(this System.Net.Sockets.Socket socket, System.ArraySegment <byte> buffer, System.Net.Sockets.SocketFlags socketFlags, System.Net.EndPoint remoteEndPoint) { throw null; }
public static System.Threading.Tasks.Task <int> ReceiveAsync(this System.Net.Sockets.Socket socket, System.ArraySegment <byte> buffer, System.Net.Sockets.SocketFlags socketFlags) { throw null; }
public ReciveState(byte[] buffer, System.Net.Sockets.SocketFlags flag) { this.buffer = buffer; this.flag = flag; }
public int Receive(byte[] arr, int offset, int size, ns.SocketFlags f) { return(realsocket.Receive(arr, offset, size, f)); }
public int Receive(byte[] arr, int offset, int size, ns.SocketFlags f, out ns.SocketError er) { return(realsocket.Receive(arr, offset, size, f, out er)); }
public int Send(byte[] arr, int offset, int size, ns.SocketFlags f, out ns.SocketError er) { return(realSocket.Send(arr, offset, size, f, out er)); }
public SendState(byte[] buffer, EndPoint target, System.Net.Sockets.SocketFlags flag) { this.buffer = buffer; this.target = target; this.flag = flag; }