Пример #1
0
 /**
  * listens and blocks until a new client connects and returns a valid {@link UDTSocket}
  * for the new connection
  * @return
  */
 public UDTSocket Accept()
 {
     lock (lock_obj)
     {
         if (!started)
         {
             endpoint.Start(true);
             started = true;
         }
         while (!shutdown)
         {
             UDTSession session = endpoint.Accept(10000);
             if (session != null)
             {
                 //wait for handshake to complete
                 while (!session.IsReady || session.Socket == null)
                 {
                     Thread.Sleep(100);
                 }
                 return(session.Socket);
             }
         }
         return(null);
     }
 }
Пример #2
0
        /**
         * establishes a connection to the given server.
         * Starts the sender thread.
         * @param host
         * @param port
         * @throws UnknownHostException
         */
        public void Connect(string host, int port)
        {
            //InetAddress address = InetAddress.getByName(host);
            Destination destination = new Destination(host, port);

            //create client session...
            clientSession = new ClientSession(clientEndpoint, destination);
            clientEndpoint.AddSession(clientSession.SocketID, clientSession);

            clientEndpoint.Start();
            clientSession.Connect();
            //wait for handshake
            while (!clientSession.IsReady)
            {
                Thread.Sleep(500);
            }
            //logger.info("The UDTClient is connected");
            Thread.Sleep(500);
        }