Beispiel #1
0
 public void SendData(CNetData datasend)
 {
     byte[] b = datasend.ToByte();
     try
     {
         clientSocket.Send(b, 0, b.Length, SocketFlags.None);
     }
     catch
     {
     }
 }
Beispiel #2
0
        private void OnConnect(IAsyncResult ar)
        {
            try
            {
                clientSocket.EndConnect(ar);

                //We are connected so we login into the server
                CNetData msgToSend = new CNetData();
                msgToSend.cmdCommand = Command.Login;
                msgToSend.intDevnum  = intDevnum;
                msgToSend.strZjbh    = null;

                byte[] b = msgToSend.ToByte();

                //Send the message to the server
                clientSocket.BeginSend(b, 0, b.Length, SocketFlags.None, new AsyncCallback(OnSend), null);
            }
            catch (Exception ex)
            {
                System.Windows.Forms.MessageBox.Show(ex.Message, "CNetClient_OnConnect", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
            }
        }