TexeL

Untitled

Jun 9th, 2013
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.72 KB | None | 0 0
  1. public void Start ()
  2.  
  3.         {
  4.  
  5.                 listenerThread = new Thread (new ThreadStart(DoListen));
  6.  
  7.                 listenerThread.Start ();
  8.  
  9.         }
  10.  
  11.  
  12.  
  13.         void OnDestroy ()
  14.  
  15.         {
  16.  
  17.                 listener.Stop ();
  18.  
  19.                 listenerThread.Abort ();
  20.  
  21.                 print ("abort");
  22.  
  23.         }
  24.  
  25.     // This subroutine is used a background listener thread to allow reading incoming
  26.  
  27.     // messages without lagging the user interface.
  28.  
  29.         private void DoListen ()
  30.  
  31.         {
  32.  
  33.                 try {
  34.  
  35.                         // Listen for new connections.
  36.  
  37.                         listener = new TcpListener (System.Net.IPAddress.Any, Port);
  38.  
  39.                         listener.Start ();
  40.  
  41.  
  42.  
  43.                         do {
  44.  
  45.                                 //Debug.Log("Listen");
  46.  
  47.                         } while(true);
  48.  
  49.                 } catch (Exception ex) {
  50.  
  51.                         Debug.Log (ex.ToString());
  52.  
  53.                 }
  54.  
  55.         }
Advertisement
Add Comment
Please, Sign In to add comment