Пример #1
0
 /// <summary>
 /// Used to begin sending data by client
 /// </summary>
 /// <param name="socket"></param>
 /// <param name="data"></param>
 public static void Send(SocketState socket, string data)
 {
     //try catch, will help indicate if a server randomly disconnected.
     try
     {
         //Save the given data to a byte and send it
         byte[] totalByte = Encoding.UTF8.GetBytes(data);
         socket.theSocket.BeginSend(totalByte, 0, totalByte.Length, SocketFlags.None, new AsyncCallback(SendCallback), socket);
     }
     catch (Exception e)
     {
         Console.WriteLine("Send Exception");
         if (socket.getFailStatus() == true)
         {
             socket.shutdownSocket();
         }
         else
         {
         }
     }
 }