Commit 672c0b6f authored by Denis Bilenko's avatar Denis Bilenko

socket: rename bind_and_listen to socket_bind_and_listen

- it no longer returns the descriptor
- the old name is still available as a deprecated alias
parent f40f6392
......@@ -601,11 +601,23 @@ def socketpair(*args):
def fromfd(*args):
return socket(_sock=_socket.fromfd(*args))
def socket_bind_and_listen(descriptor, addr=('', 0), backlog=50):
set_reuse_addr(descriptor)
def bind_and_listen(descriptor, addr=('', 0), backlog=50, reuse_addr=True):
if reuse_addr:
try:
descriptor.setsockopt(SOL_SOCKET, SO_REUSEADDR, descriptor.getsockopt(SOL_SOCKET, SO_REUSEADDR) | 1)
except error:
pass
descriptor.bind(addr)
descriptor.listen(backlog)
return descriptor
def socket_bind_and_listen(*args, **kwargs):
import warnings
warnings.warn("gevent.socket.socket_bind_and_listen is renamed to bind_and_listen", DeprecationWarning, stacklevel=2)
bind_and_listen(*args, **kwargs)
return args[0]
def set_reuse_addr(descriptor):
try:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment