rbb 99/04/15 07:57:32
Modified: docs networkio.txt include apr_network_io.h apr/network_io/unix sockets.c Log: Add apr_accept function. Revision Changes Path 1.8 +4 -5 apache-apr/docs/networkio.txt Index: networkio.txt =================================================================== RCS file: /home/cvs/apache-apr/docs/networkio.txt,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- networkio.txt 1999/04/14 21:03:01 1.7 +++ networkio.txt 1999/04/15 14:57:30 1.8 @@ -120,17 +120,16 @@ arg 2) The size of the listen queue. return) APR_SUCCESS or APR_FAILURE - APRStatus apr_accept(APRSocket, APRNetAddr *, APRSocket *) + apr_socket_t *apr_accept(apr_socket_t *) extract first connection from listen queue, and sets up a new connection on a new socket of the same type and family. It allocates a new socket for that connection. Arguments: arg 1) The file desc of a socket that is listening. The connection comes from this socket's listen queue. - arg 2) structure to store address of connecting socket. - arg 3) file descriptor of created socket. -1 on failure. - NOTE: accepted socket can not accept more connections. Original socket - remains open, and can accept more connections. + return) new socket that has the accepted connection. +NOTE: accepted socket can not accept more connections. Original socket + remains open, and can accept more connections. 1.6 +2 -0 apache-apr/include/apr_network_io.h Index: apr_network_io.h =================================================================== RCS file: /home/cvs/apache-apr/include/apr_network_io.h,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- apr_network_io.h 1999/04/14 21:04:12 1.5 +++ apr_network_io.h 1999/04/15 14:57:31 1.6 @@ -82,8 +82,10 @@ apr_socket_t *apr_create_tcp_socket(void); apr_status_t apr_shutdown(apr_socket_t *, apr_shutdown_how_t); apr_status_t apr_close_socket(apr_socket_t *); + apr_status_t apr_bind(apr_socket_t *); apr_status_t apr_listen(apr_socket_t *, apr_int32_t); +apr_socket_t *apr_accept(const apr_socket_t *); apr_ssize_t apr_send(apr_socket_t *, const char *, int, time_t); apr_ssize_t apr_recv(apr_socket_t *, char *, int, time_t); 1.3 +13 -0 apache-apr/apr/network_io/unix/sockets.c Index: sockets.c =================================================================== RCS file: /home/cvs/apache-apr/apr/network_io/unix/sockets.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- sockets.c 1999/04/14 21:02:07 1.2 +++ sockets.c 1999/04/15 14:57:31 1.3 @@ -126,3 +126,16 @@ else return APR_SUCCESS; } + +apr_socket_t *apr_accept(const apr_socket_t *sock) +{ + apr_socket_t *new = (apr_socket_t *)malloc(sizeof(apr_socket_t)); + + new->socketdes = accept(sock->socketdes, (struct sockaddr *)new->addr, new->addr_len); + + if (new->socketdes >= 0) + return new; + return NULL; +} + +