Ejemplo n.º 1
0
        /// <summary>
        /// Initializes a new <see cref="NetworkConnection{TPacket}"/> with an established socket
        /// </summary>
        /// <param name="Socket">The connected <see cref="Socket"/></param>
        /// <param name="PacketSizeLength">The amount of <see langword="bytes"/> used to represent packet size</param>
        public NetworkConnection(Socket Socket, int PacketSizeLength)
        {
            _Socket = Socket;

            _Socket.SendTimeout    = Send_Timeout;
            _Socket.ReceiveTimeout = Receive_Timeout;

            _Socket.NoDelay = true;

            _Buffer = new NetworkBuffer(BufferState.Size, 2);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Initializes a new <see cref="NetworkConnection{TPacket}"/>, without connecting
        /// </summary>
        /// <param name="Type">The <see cref="SocketType"/> of the underlying <see cref="Socket"/></param>
        /// <param name="Protocol">The <see cref="ProtocolType"/> of the underlying <see cref="Socket"/></param>
        /// <param name="PacketSizeLength">The amount of <see langword="bytes"/> used to represent packet size</param>
        public NetworkConnection(SocketType Type, ProtocolType Protocol, int PacketSizeLength)
        {
            this.Protocol = Protocol;

            _Socket = new Socket(Type, Protocol);

            _Socket.SendTimeout    = Send_Timeout;
            _Socket.ReceiveTimeout = Receive_Timeout;

            _Buffer = new NetworkBuffer(BufferState.Size, 2);
        }