@@ -249,17 +249,21 @@ def close(self):
249249 # WORK IN PROGRESS
250250 ####################################################################
251251
252- def setsockopt (self , * opts , ** kwopts ):
253- """Dummy call for compatibility."""
254-
255- def setblocking (self , flag : bool ):
256- """Set the blocking behaviour of this socket.
257- :param bool flag: False means non-blocking, True means block indefinitely.
252+ def accept (self ):
253+ """Accept a connection on a listening socket of type SOCK_STREAM,
254+ creating a new socket of type SOCK_STREAM. Returns a tuple of
255+ (new_socket, remote_address)
258256 """
259- if flag :
260- self .settimeout (None )
261- else :
262- self .settimeout (0 )
257+ client_sock_num = self ._interface .socket_available (self ._socknum )
258+ if client_sock_num != SocketPool .NO_SOCKET_AVAIL :
259+ sock = Socket (self ._socket_pool , socknum = client_sock_num )
260+ # get remote information (addr and port)
261+ remote = self ._interface .get_remote_data (client_sock_num )
262+ ip_address = "{}.{}.{}.{}" .format (* remote ["ip_addr" ])
263+ port = remote ["port" ]
264+ client_address = (ip_address , port )
265+ return sock , client_address
266+ raise OSError (errno .ECONNRESET )
263267
264268 def bind (self , address : Tuple [str , int ]):
265269 """Bind a socket to an address"""
@@ -274,18 +278,14 @@ def listen(self, backlog: int): # pylint: disable=unused-argument
274278 port = self ._bound [1 ]
275279 self ._interface .start_server (port , self ._socknum )
276280
277- def accept (self ):
278- """Accept a connection on a listening socket of type SOCK_STREAM,
279- creating a new socket of type SOCK_STREAM. Returns a tuple of
280- (new_socket, remote_address)
281+ def setblocking (self , flag : bool ):
282+ """Set the blocking behaviour of this socket.
283+ :param bool flag: False means non-blocking, True means block indefinitely.
281284 """
282- client_sock_num = self ._interface .socket_available (self ._socknum )
283- if client_sock_num != SocketPool .NO_SOCKET_AVAIL :
284- sock = Socket (self ._socket_pool , socknum = client_sock_num )
285- # get remote information (addr and port)
286- remote = self ._interface .get_remote_data (client_sock_num )
287- ip_address = "{}.{}.{}.{}" .format (* remote ["ip_addr" ])
288- port = remote ["port" ]
289- client_address = (ip_address , port )
290- return sock , client_address
291- raise OSError (errno .ECONNRESET )
285+ if flag :
286+ self .settimeout (None )
287+ else :
288+ self .settimeout (0 )
289+
290+ def setsockopt (self , * opts , ** kwopts ):
291+ """Dummy call for compatibility."""
0 commit comments