* changed prototype of net_strerror()
authorUrban Wallasch <urban.wallasch@freenet.de>
Tue, 22 Oct 2019 16:45:59 +0000 (18:45 +0200)
committerUrban Wallasch <urban.wallasch@freenet.de>
Tue, 22 Oct 2019 16:45:59 +0000 (18:45 +0200)
* improved comments

net/net.c
net/net.h

index 89e8da04ed29529f030d97e908ec14abd2a5aba5..9991c6b81e634963fcd5e9a8d54ec4c1a159feba 100644 (file)
--- a/net/net.c
+++ b/net/net.c
@@ -276,7 +276,7 @@ int tcp_accept(int sock, int timeout) {
 }
 
 /* Copy textual description of last error to user supplied buffer: */
-const char *net_strerror(int errnum, char *buf, size_t len) {
+char *net_strerror(int errnum, char *buf, size_t len) {
     if ( errnum == EAI_SYSTEM )
         strerror_r(errno, buf, len);
     else
index c430046db626d94ea19a35dfe4af56423d25e0f0..33c09e2bbda111d16f18f230a6ba5025b2e3db8c 100644 (file)
--- a/net/net.h
+++ b/net/net.h
@@ -23,7 +23,8 @@ extern "C" {
  * 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)
@@ -31,6 +32,9 @@ extern "C" {
  * 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);
 
@@ -46,10 +50,11 @@ 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)
@@ -72,7 +77,8 @@ extern int net_open_client(const char *host, const char *svc, const char *addr,
 
 /*
  * 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
  */
@@ -82,6 +88,7 @@ extern int net_close(int sock);
 /*
  * 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.
  *
@@ -89,15 +96,16 @@ extern int net_close(int sock);
  * 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
@@ -107,7 +115,7 @@ extern int tcp_accept(int sock, int timeout);
  * 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