* Create a new socket with the specified characteristics, bind it to
* the local node address and, in case of SOCK_STREAM, start listening
* for connection requests which can be accepted using tcp_accept().
- * Returns the listener socket or a negative value on error.
+ *
+ * Returns the bound listener socket, or a negative value on error.
*
* addr - <string> local node address (numerical or name); NULL for any
* svc - <string> service (port number or service name)
* af - <int> address family; one of AF_UNSPEC, AF_INET, AF_INET6
*
* Note: Address family AF_INET6 will still allow V4MAPPED connections.
+ * AF_UNSPEC will cause the first suitable bind address to be used,
+ * the sort order is determined by the host configuration, e.g. in
+ * /etc/gai.conf for glibc.
*/
extern int net_open_server(const char *addr, const char *svc, int st, int af);
/*
- * Create a new socket, optionally bind it to a local node, associate
- * it with a random ephemeral port and connect it to the specified host
- * and service.
- * Returns the connected socket or a negative value on error.
+ * Create a new socket, optionally bind it to a local node address,
+ * associate it with a random ephemeral port and connect it to the
+ * specified host and service.
+ *
+ * Returns the connected socket, or a negative value on error.
*
* host - <string> remote node address (numerical or host name)
* svc - <string> remote service (port number or service name)
/*
* Shutdown and close the specified socket.
- * Returns 0 on success or a negative value on error.
+ *
+ * Returns 0 on success, or a negative value on error.
*
* sock - <int> socket to close
*/
/*
* Wait at most timeout milliseconds for a TCP connection request on
* a listener socket to arrive and accept any such request.
+ *
* Returns a newly created socket associated with the accepted TCP
* connection, or a negative value on error.
*
* timeout - <int> timeout in milliseconds
*
* Note: A time-out condition is considered an error, and errno is set
- * to ETIMEDOUT. A negative value for timeout lets tcp_accept() block
- * indefinitely. Set timeout to zero for immediate and non-blocking
- * operation.
+ * to ETIMEDOUT. A negative value for timeout will cause tcp_accept()
+ * to wait indefinitely. Set the timeout to zero for immediate and
+ * non-blocking operation.
*/
extern int tcp_accept(int sock, int timeout);
/*
* Copy textual description of last error to user supplied buffer.
+ *
* Returns a pointer to the buffer.
*
* errnum - <int> error code returned by any of the above functions
* Note: Depending on the actual value of errnum this function will
* return a message based on either strerror_r() or gai_strerror().
*/
-extern const char *net_strerror(int errnum, char *buf, size_t len);
+extern char *net_strerror(int errnum, char *buf, size_t len);
#ifdef cplusplus