コード例 #1
0
 public void rundispatcher()
 {
     // 무한히 실행하면서 연결 요청을 수락하고 처리한다.
     for (; ;)
     {
         try {
             Socket    clntSock = listener.AcceptSocket();   // 블록을 걸고서 연결을 대기한다.
             IProtocol protocol = protoFactory.createProtocol(clntSock, logger);
             protocol.handleclient();
         }
         catch (SocketException se) {
             logger.writeEntry("Exception = " + se.Message);
         }
     }
 }
コード例 #2
0
    public void startDispatching(TcpListener listener, ILogger logger,
                               IProtocolFactory protoFactory)
    {
        // Run forever, accepting and spawning threads to service each connection

        for (;;) {
          try {
        listener.Start();
        Socket clntSock = listener.AcceptSocket();  // Block waiting for connection
        IProtocol protocol = protoFactory.createProtocol(clntSock, logger);
        Thread thread = new Thread(new ThreadStart(protocol.handleclient));
        thread.Start();
        logger.writeEntry("Created and started Thread = " + thread.GetHashCode());
          } catch (System.IO.IOException e) {
        logger.writeEntry("Exception = " + e.Message);
          }
        }
        /* NOT REACHED */
    }
コード例 #3
0
 public void startDispatching(TcpListener listener, ILogger logger,
                              IProtocolFactory protoFactory)
 {
     // 무한히 실행하면서 연결 요청을 수락할 때마다 새로운 서비스 스레드를 생성한다.
     for (; ;)
     {
         try {
             listener.Start();
             Socket    clntSock = listener.AcceptSocket();   // 연결 요청을 대기하면서 블록을 건다.
             IProtocol protocol = protoFactory.createProtocol(clntSock, logger);
             Thread    thread   = new Thread(new ThreadStart(protocol.handleclient));
             thread.Start();
             logger.writeEntry("Created and started Thread = " + thread.GetHashCode());
         }
         catch (System.IO.IOException e) {
             logger.writeEntry("Exception = " + e.Message);
         }
     }
     // 이 곳으로는 도달하지 않는다.
 }