diff options
-rw-r--r-- | CHANGES | 3 | ||||
-rw-r--r-- | include/apr_network_io.h | 9 | ||||
-rw-r--r-- | network_io/os2/sockets.c | 5 | ||||
-rw-r--r-- | network_io/unix/sockets.c | 6 | ||||
-rw-r--r-- | network_io/win32/sockets.c | 6 | ||||
-rw-r--r-- | test/testsockets.c | 12 |
6 files changed, 40 insertions, 1 deletions
@@ -7,6 +7,9 @@ Changes for APR 1.1 [Deferring these features when 1.0 is rolled out.] Changes with APR 1.0 + *) Add apr_socket_type_get() for retrieving the type (e.g., stream) + of the socket. [Philippe M. Chiasson gozer cpan.org] + *) Removed deprecated interface apr_proc_other_child_check() that behaved differently between win32 and unix. The unix behavor is now accomplished with diff --git a/include/apr_network_io.h b/include/apr_network_io.h index 27e706f72..9449fdc81 100644 --- a/include/apr_network_io.h +++ b/include/apr_network_io.h @@ -727,7 +727,14 @@ APR_DECLARE(apr_status_t) apr_sockaddr_ip_get(char **addr, APR_DECLARE(int) apr_sockaddr_equal(const apr_sockaddr_t *addr1, const apr_sockaddr_t *addr2); - +/** +* Return the type of the socket. +* @param sock The socket to query. +* @param type The returned type (e.g., SOCK_STREAM). +*/ +APR_DECLARE(apr_status_t) apr_socket_type_get(apr_socket_t *sock, + int *type); + /** * Given an apr_sockaddr_t and a service name, set the port for the service * @param sockaddr The apr_sockaddr_t that will have its port set diff --git a/network_io/os2/sockets.c b/network_io/os2/sockets.c index 66949b573..b58c046e7 100644 --- a/network_io/os2/sockets.c +++ b/network_io/os2/sockets.c @@ -240,6 +240,11 @@ APR_DECLARE(apr_status_t) apr_socket_connect(apr_socket_t *sock, } } +APR_DECLARE(apr_status_t) apr_socket_type_get(apr_socket_t *sock, int *type) +{ + *type = sock->type; + return APR_SUCCESS; +} APR_DECLARE(apr_status_t) apr_socket_data_get(void **data, const char *key, apr_socket_t *sock) diff --git a/network_io/unix/sockets.c b/network_io/unix/sockets.c index 1c1638932..52bf434c9 100644 --- a/network_io/unix/sockets.c +++ b/network_io/unix/sockets.c @@ -317,6 +317,12 @@ apr_status_t apr_socket_connect(apr_socket_t *sock, apr_sockaddr_t *sa) return APR_SUCCESS; } +apr_status_t apr_socket_type_get(apr_socket_t *sock, int *type) +{ + *type = sock->type; + return APR_SUCCESS; +} + apr_status_t apr_socket_data_get(void **data, const char *key, apr_socket_t *sock) { sock_userdata_t *cur = sock->userdata; diff --git a/network_io/win32/sockets.c b/network_io/win32/sockets.c index b03f8813c..55f31140f 100644 --- a/network_io/win32/sockets.c +++ b/network_io/win32/sockets.c @@ -401,6 +401,12 @@ APR_DECLARE(apr_status_t) apr_socket_connect(apr_socket_t *sock, return APR_SUCCESS; } +APR_DECLARE(apr_status_t) apr_socket_type_get(apr_socket_t *sock, int *type) +{ + *type = sock->type; + return APR_SUCCESS; +} + APR_DECLARE(apr_status_t) apr_socket_data_get(void **data, const char *key, apr_socket_t *sock) { diff --git a/test/testsockets.c b/test/testsockets.c index 87f46a027..1ba2ea111 100644 --- a/test/testsockets.c +++ b/test/testsockets.c @@ -72,10 +72,16 @@ static void tcp_socket(CuTest *tc) { apr_status_t rv; apr_socket_t *sock = NULL; + int type; rv = apr_socket_create(&sock, APR_INET, SOCK_STREAM, 0, p); CuAssertIntEquals(tc, APR_SUCCESS, rv); CuAssertPtrNotNull(tc, sock); + + rv = apr_socket_type_get(sock, &type); + CuAssertIntEquals(tc, APR_SUCCESS, rv); + CuAssertIntEquals(tc, SOCK_STREAM, type); + apr_socket_close(sock); } @@ -83,10 +89,16 @@ static void udp_socket(CuTest *tc) { apr_status_t rv; apr_socket_t *sock = NULL; + int type; rv = apr_socket_create(&sock, APR_INET, SOCK_DGRAM, 0, p); CuAssertIntEquals(tc, APR_SUCCESS, rv); CuAssertPtrNotNull(tc, sock); + + rv = apr_socket_type_get(sock, &type); + CuAssertIntEquals(tc, APR_SUCCESS, rv); + CuAssertIntEquals(tc, SOCK_DGRAM, type); + apr_socket_close(sock); } |