Esempio n. 1
0
        /// <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;
        }
Esempio n. 2
0
        /// <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;
        }
Esempio n. 3
0
        /// <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;
        }
Esempio n. 4
0
        /// <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>();
        }
Esempio n. 5
0
        /// <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>();
        }
Esempio n. 6
0
        /// <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;
        }
Esempio n. 7
0
        /// <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;
        }
Esempio n. 8
0
        /// <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;
        }