Beispiel #1
0
 static void cmdAccept()
 {
     Console.WriteLine("accept: Waiting for a connection...");
     try
     {
         if (RemoteSkt != null)
         {
             RemoteSkt.Close();
         }
         RemoteSkt = LocalSkt.Accept();
     }
     catch (Exception)
     {
         Console.WriteLine("accept: Failed to accept");
     }
 }
Beispiel #2
0
 static void cmdSend(string[] cmd)
 {
     if (RemoteSkt == null || RemoteSkt.Connected == false)
     {
         Console.WriteLine("send: Not connected to remote host");
         return;
     }
     try
     {
         byte[] msg = Encoding.ASCII.GetBytes(Data[cmd[1]]);
         RemoteSkt.Send(msg);
     }
     catch (Exception)
     {
         Console.WriteLine("send: Sending to remote host failed.");
     }
 }
Beispiel #3
0
 static void cmdRecv(string[] cmd)
 {
     if (RemoteSkt == null || RemoteSkt.Connected == false)
     {
         Console.WriteLine("recv: Not connected to remote host");
         return;
     }
     try
     {
         byte[] msg = new byte[RemoteSkt.Available];
         RemoteSkt.Receive(msg);
         Data[cmd[1]] = Encoding.ASCII.GetString(msg);
     }
     catch (Exception)
     {
         Console.WriteLine("recv: Recieveing from remote host failed.");
     }
 }
Beispiel #4
0
 static void cmdDisconn()
 {
     if (RemoteSkt == null)
     {
         Console.WriteLine("disconn: Alredy disconnected");
         return;
     }
     try
     {
         RemoteSkt.Disconnect(false);
         RemoteSkt = null;
         if (LocalSkt.Connected)
         {
             LocalSkt.Disconnect(true);
         }
     }
     catch (Exception)
     {
         Console.WriteLine("disconn: Failed to disconnect");
     }
 }