コード例 #1
0
        internal void Start()
        {
            try
            {
                _ns = _tc.GetStream();
                Tcp.FormatIPStringToTcpStruct(_tc.Client.RemoteEndPoint.ToString(), ref _remoteTcpStruct);

                _tcp.onConnectionEvent(_tcp._localTcpStruct, _remoteTcpStruct, this, ClientID);
                _tcp.onTcpEvents(_tcp._localTcpStruct, _remoteTcpStruct, TcpOptionType.ClientConnected, this);

                if (!_tc.Connected)
                {
                    close();
                    return;
                }

                int bit = 0;
                while ((bit = _ns.ReadByte()) != -1)
                {
                    DataLoop((byte)bit, _clientID);
                }
                close();
            }
            catch { close(); }
        }
コード例 #2
0
        internal void Start()
        {
            try
            {
                _ns = _tc.GetStream();
                Tcp.FormatIPStringToTcpStruct(_tc.Client.RemoteEndPoint.ToString(), ref _remoteTcpStruct);

                _tcp.onConnectionEvent(_tcp._localTcpStruct, _remoteTcpStruct, this, ClientID);
                _tcp.onTcpEvents(_tcp._localTcpStruct, _remoteTcpStruct, TcpOptionType.ClientConnected, this);

                if (!_tc.Connected)
                {
                    close();
                    return;
                }
                int dataSize = 0;
                _bufferSize = _tc.ReceiveBufferSize;
                byte[] cacheByte = new byte[_bufferSize];
                while ((dataSize = _ns.Read(cacheByte, 0, cacheByte.Length)) > 0)
                {
                    byte[] data = new byte[dataSize];
                    for (int i = 0; i < dataSize; i++)
                    {
                        data[i] = cacheByte[i];
                    }

                    onReceivedData(_tcp._localTcpStruct, _remoteTcpStruct, data, _clientID);
                }
                close();
            }
            catch { close(); }
        }