Example #1
0
 private void OnConnect()
 {
     try
     {
         txtError.Text = "";
         uint   dummy          = 0;
         byte[] inOptionValues = new byte[Marshal.SizeOf(dummy) * 3];
         BitConverter.GetBytes((uint)1).CopyTo(inOptionValues, 0);
         BitConverter.GetBytes((uint)5000).CopyTo(inOptionValues, Marshal.SizeOf(dummy));
         BitConverter.GetBytes((uint)5000).CopyTo(inOptionValues, Marshal.SizeOf(dummy) * 2);
         mChannel = TcpServer.CreateClient(txtIPAddress.Text, 9001);
         mChannel.Socket.IOControl(IOControlCode.KeepAliveValues, inOptionValues, null);
         mChannel.ChannelError    += onerror;
         mChannel.ChannelDisposed += ondisposed;
         mChannel.SetPackage <Logic.HeadSizePage>();
         mChannel.Package.ReceiveMessage = OnReceive;
         mChannel.BeginReceive();
         Logic.Register register = new Logic.Register();
         register.Name = txtUserName.Text;
         mChannel.Send(register);
     }
     catch (Exception e_)
     {
         MessageBox.Show(this, e_.Message, "error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }