Made socket non-blocking mode in SocketCore::beginListen()

pull/36/head
Tatsuhiro Tsujikawa 2012-11-28 00:15:03 +09:00
parent 438f95abae
commit e781e6eac1
6 changed files with 3 additions and 3 deletions

View File

@ -206,7 +206,6 @@ SharedHandle<SocketCore> FtpConnection::createServerSocket()
SharedHandle<SocketCore> serverSocket(new SocketCore());
serverSocket->bind(addrinfo.first.c_str(), 0, AF_UNSPEC);
serverSocket->beginListen();
serverSocket->setNonBlockingMode();
return serverSocket;
}

View File

@ -106,7 +106,6 @@ bool HttpListenCommand::bindPort(uint16_t port)
}
serverSocket_->bind(0, port, family_, flags);
serverSocket_->beginListen();
serverSocket_->setNonBlockingMode();
A2_LOG_INFO(fmt(MSG_LISTENING_PORT,
getCuid(), port));
e_->addSocketForReadCheck(serverSocket_, this);

View File

@ -79,7 +79,6 @@ bool PeerListenCommand::bindPort(uint16_t& port, SegList<int>& sgl)
try {
socket_->bind(0, port, family_);
socket_->beginListen();
socket_->setNonBlockingMode();
A2_LOG_NOTICE(fmt(_("IPv%d BitTorrent: listening to port %u"),
ipv, port));
return true;

View File

@ -353,6 +353,7 @@ void SocketCore::beginListen()
int errNum = SOCKET_ERRNO;
throw DL_ABORT_EX(fmt(EX_SOCKET_LISTEN, errorMsg(errNum).c_str()));
}
setNonBlockingMode();
}
SharedHandle<SocketCore> SocketCore::acceptConnection() const

View File

@ -52,6 +52,7 @@ public:
SharedHandle<SocketCore> listenSocket(new SocketCore());
listenSocket->bind(0);
listenSocket->beginListen();
listenSocket->setBlockingMode();
std::pair<std::string, uint16_t> addrinfo;
listenSocket->getAddrInfo(addrinfo);
listenPort_ = addrinfo.second;

View File

@ -53,6 +53,7 @@ createSocketPair()
SocketCore receiverServerSock;
receiverServerSock.bind(0);
receiverServerSock.beginListen();
receiverServerSock.setBlockingMode();
std::pair<std::string, uint16_t> receiverAddrInfo;
receiverServerSock.getAddrInfo(receiverAddrInfo);