示例#1
0
        static public void SendVersion()
        {
            VERSION_REQ person = new VERSION_REQ
            {
            };

            using (MemoryStream stream = new MemoryStream())
            {
                person.WriteTo(stream);

                client.WritePacket((int)PROTOCOL.IdPktVersionReq, stream.ToArray(), stream.ToArray().Length);
            }
        }
示例#2
0
        public void StartClient(string address, int port)
        {
            // Connect to a remote device.
            try
            {
                IPAddress ip = IPAddress.Parse(address);

                IPEndPoint remoteEP = new IPEndPoint(ip, port);

                if (socket != null)
                // Create a TCP/IP socket.
                {
                    if (socket.Connected == true)
                    {
                        return;
                    }

                    socket.Dispose();
                    socket = null;
                    socket = new Socket(AddressFamily.InterNetwork,
                                        SocketType.Stream, ProtocolType.Tcp);
                }
                else
                {
                    socket = new Socket(AddressFamily.InterNetwork,
                                        SocketType.Stream, ProtocolType.Tcp);
                }

                socket.Connect(remoteEP);


                VERSION_REQ person = new VERSION_REQ
                {
                };
                using (MemoryStream stream = new MemoryStream())
                {
                    person.WriteTo(stream);

                    WritePacket((int)PROTOCOL.IdPktVersionReq, stream.ToArray(), stream.ToArray().Length);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
            }
        }
示例#3
0
        static public void SendVersion()
        {
            if (client == null || client.socket == null || client.socket.Connected == false)
            {
                return;
            }

            VERSION_REQ person = new VERSION_REQ
            {
            };

            using (MemoryStream stream = new MemoryStream())
            {
                person.WriteTo(stream);

                client.WritePacket((int)PROTOCOL.IdPktVersionReq, stream.ToArray(), stream.ToArray().Length);
            }
        }