@@ -226,7 +226,14 @@ def remove_writer(self, fd):
226226 return False
227227
228228 def sock_recv (self , sock , n ):
229- """XXX"""
229+ """Receive data from the socket.
230+
231+ The return value is a bytes object representing the data received.
232+ The maximum amount of data to be received at once is specified by
233+ nbytes.
234+
235+ This method is a coroutine.
236+ """
230237 fut = futures .Future (loop = self )
231238 self ._sock_recv (fut , False , sock , n )
232239 return fut
@@ -253,7 +260,16 @@ def _sock_recv(self, fut, registered, sock, n):
253260 fut .set_result (data )
254261
255262 def sock_sendall (self , sock , data ):
256- """XXX"""
263+ """Send data to the socket.
264+
265+ The socket must be connected to a remote socket. This method continues
266+ to send data from data until either all data has been sent or an
267+ error occurs. None is returned on success. On error, an exception is
268+ raised, and there is no way to determine how much data, if any, was
269+ successfully processed by the receiving end of the connection.
270+
271+ This method is a coroutine.
272+ """
257273 fut = futures .Future (loop = self )
258274 if data :
259275 self ._sock_sendall (fut , False , sock , data )
@@ -285,7 +301,16 @@ def _sock_sendall(self, fut, registered, sock, data):
285301 self .add_writer (fd , self ._sock_sendall , fut , True , sock , data )
286302
287303 def sock_connect (self , sock , address ):
288- """XXX"""
304+ """Connect to a remote socket at address.
305+
306+ The address must be already resolved to avoid the trap of hanging the
307+ entire event loop when the address requires doing a DNS lookup. For
308+ example, it must be an IP address, not an hostname, for AF_INET and
309+ AF_INET6 address families. Use getaddrinfo() to resolve the hostname
310+ asynchronously.
311+
312+ This method is a coroutine.
313+ """
289314 fut = futures .Future (loop = self )
290315 try :
291316 base_events ._check_resolved_address (sock , address )
@@ -318,7 +343,15 @@ def _sock_connect(self, fut, registered, sock, address):
318343 fut .set_result (None )
319344
320345 def sock_accept (self , sock ):
321- """XXX"""
346+ """Accept a connection.
347+
348+ The socket must be bound to an address and listening for connections.
349+ The return value is a pair (conn, address) where conn is a new socket
350+ object usable to send and receive data on the connection, and address
351+ is the address bound to the socket on the other end of the connection.
352+
353+ This method is a coroutine.
354+ """
322355 fut = futures .Future (loop = self )
323356 self ._sock_accept (fut , False , sock )
324357 return fut
0 commit comments