Ejemplo n.º 1
0
 public static void initializeNetwork()
 {
     Console.WriteLine("inizializzazione pacchetti ... ");
     ServerHandlData.InizializzaPacchetti();
     serversocket.Start();
     serversocket.BeginAcceptTcpClient(new AsyncCallback(OnClientConnect), null); // accetta un client
 }
Ejemplo n.º 2
0
 private void OnReceiveData(IAsyncResult result)
 {
     try
     {
         int length = stream.EndRead(result);
         if (length <= 0)
         {
             CloseConnection();
             return;
         }
         byte[] newbytes = new byte[length];
         Array.Copy(reciverbuffer, newbytes, length);
         ServerHandlData.HandleData(COnnectionID, newbytes);
         stream.BeginRead(reciverbuffer, 0, socket.ReceiveBufferSize, OnReceiveData, null);
     }
     catch (Exception)
     {
         return;
     }
 }