httpserver.py 文件源码

python
阅读 29 收藏 0 点赞 0 评论 0

项目:annotated-py-tornado 作者: hhstore 项目源码 文件源码
def bind(self, port, address=""):
        """Binds this server to the given port on the given IP address.

        To start the server, call start(). If you want to run this server
        in a single process, you can call listen() as a shortcut to the
        sequence of bind() and start() calls.
        """
        assert not self._socket

        # ?? socket
        self._socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM, 0)

        flags = fcntl.fcntl(self._socket.fileno(), fcntl.F_GETFD)
        flags |= fcntl.FD_CLOEXEC
        fcntl.fcntl(self._socket.fileno(), fcntl.F_SETFD, flags)
        self._socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
        self._socket.setblocking(0)

        # ?? socket
        self._socket.bind((address, port))
        # ?? socket
        self._socket.listen(128)
评论列表


问题


面经


文章

微信
公众号

扫码关注公众号