Example #1
0
 public override void SendMessage(string message)
 {
     try
     {
         ObjSocket.Send(new byte[1] {
             (byte)message.Length
         });
         ObjSocket.Send(Encoding.ASCII.GetBytes(message));
     }
     catch (Exception exception)
     {
         Console.WriteLine("Message send failed with message: {0}", exception.Message);
     }
 }
Example #2
0
        public override void Connect(string ipString, int port)
        {
            IPEndPoint destPoint = new IPEndPoint(IPAddress.Parse(ipString), port);

            try
            {
                ObjSocket.Connect(destPoint);
                ObjSocket.Send(new byte[1] {
                    (byte)NickName.Length
                });
                ObjSocket.Send(Encoding.ASCII.GetBytes(NickName));
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception.Message);
            }
            finally
            {
                Console.WriteLine("Connection established");
                InnerThread = new Thread(new ThreadStart(MessageHandler));
                InnerThread.Start();
            }
        }