/// <summary> /// Constructor de Servidor /// </summary> /// <param name="protocol">Protocolo</param> /// <param name="port">Puerto para leer</param> public XPloitSocket(IXPloitSocketProtocol protocol, ushort port) { if (protocol == null) { throw (new ArgumentNullException("protocol")); } _Protocol = protocol; _IPEndPoint = new IPEndPoint(IPAddress.Any, port); IsServer = true; }
/// <summary> /// Constructor de cliente /// </summary> /// <param name="protocol">Protocolo</param> /// <param name="host">Host</param> /// <param name="port">Puerto</param> public XPloitSocket(IXPloitSocketProtocol protocol, IPAddress host, ushort port, bool asServer) { if (protocol == null) { throw (new ArgumentNullException("protocol")); } _Protocol = protocol; _IPEndPoint = new IPEndPoint(host == null ? IPAddress.Any : host, port); IsServer = asServer; }
/// <summary> /// Constructor de cliente /// </summary> /// <param name="protocol">Protocolo</param> /// <param name="hostAndPort">Host y puerto</param> public XPloitSocket(IXPloitSocketProtocol protocol, string hostAndPort) { if (protocol == null) { throw (new ArgumentNullException("protocol")); } ushort port = DEFAULT_PORT; IPAddress host = null; if (!IPHelper.ParseIpPort(hostAndPort, out host, ref port)) { throw (new ArgumentNullException("Host")); } _Protocol = protocol; _IPEndPoint = new IPEndPoint(host, port); IsServer = false; }
/// <summary> /// Constructor /// </summary> /// <param name="protocol">Protocol</param> /// <param name="socket">Socket</param> /// <param name="speedLimit">Use speedLimit</param> public XPloitSocketClient(IXPloitSocketProtocol protocol, Socket socket, bool speedLimit) { _Protocol = protocol; _LocalEndPoint = socket.LocalEndPoint; _RemoteEndPoint = socket.RemoteEndPoint; socket.NoDelay = true; socket.Blocking = true; socket.DontFragment = true; socket.SendTimeout = 0; socket.ReceiveBufferSize = 0; socket.SendBufferSize = 0; socket.ReceiveTimeout = 0; try { socket.SendBufferSize = _dfbl; socket.ReceiveBufferSize = _dfbl; if (speedLimit) { _Stream = new StreamSpeedLimit(new NetworkStream(socket), StreamSpeedLimit.Infinite); } else { _Stream = new NetworkStream(socket); } _IPEndPoint = ((IPEndPoint)socket.RemoteEndPoint); } catch { } _Socket = socket; _Variables = new Dictionary <string, object>(); }
/// <summary> /// Constructor /// </summary> /// <param name="protocol">Protocol</param> /// <param name="socket">Socket</param> /// <param name="speedLimit">Use speedLimit</param> public XPloitSocketClient(IXPloitSocketProtocol protocol, Socket socket, bool speedLimit) { _Protocol = protocol; _LocalEndPoint = socket.LocalEndPoint; _RemoteEndPoint = socket.RemoteEndPoint; socket.NoDelay = true; socket.Blocking = true; socket.DontFragment = true; socket.SendTimeout = 0; socket.ReceiveBufferSize = 0; socket.SendBufferSize = 0; socket.ReceiveTimeout = 0; try { socket.SendBufferSize = _dfbl; socket.ReceiveBufferSize = _dfbl; if (speedLimit) _Stream = new StreamSpeedLimit(new NetworkStream(socket), StreamSpeedLimit.Infinite); else _Stream = new NetworkStream(socket); _IPEndPoint = ((IPEndPoint)socket.RemoteEndPoint); } catch { } _Socket = socket; _Variables = new Dictionary<string, object>(); }
/// <summary> /// Constructor de Servidor /// </summary> /// <param name="protocol">Protocolo</param> /// <param name="port">Puerto para leer</param> public XPloitSocket(IXPloitSocketProtocol protocol, ushort port) { if (protocol == null) throw (new ArgumentNullException("protocol")); _Protocol = protocol; _IPEndPoint = new IPEndPoint(IPAddress.Any, port); IsServer = true; }
/// <summary> /// Constructor de cliente /// </summary> /// <param name="protocol">Protocolo</param> /// <param name="host">Host</param> /// <param name="port">Puerto</param> public XPloitSocket(IXPloitSocketProtocol protocol, IPAddress host, ushort port, bool asServer) { if (protocol == null) throw (new ArgumentNullException("protocol")); _Protocol = protocol; _IPEndPoint = new IPEndPoint(host == null ? IPAddress.Any : host, port); IsServer = asServer; }
/// <summary> /// Constructor de cliente /// </summary> /// <param name="protocol">Protocolo</param> /// <param name="hostAndPort">Host y puerto</param> public XPloitSocket(IXPloitSocketProtocol protocol, string hostAndPort) { if (protocol == null) throw (new ArgumentNullException("protocol")); ushort port = DEFAULT_PORT; IPAddress host = null; if (!IPHelper.ParseIpPort(hostAndPort, out host, ref port)) { throw (new ArgumentNullException("Host")); } _Protocol = protocol; _IPEndPoint = new IPEndPoint(host, port); IsServer = false; }