apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Philippe M. Chiasson" <go...@cpan.org>
Subject [Patch] apr_socket_type_get()
Date Mon, 03 Feb 2003 09:37:01 GMT
When mixing UDP and TCP sockets, it's very usefull to know of what type
they are. For example, to know if one should call recv() or recvfrom(),
send() or sendto(), etc...

Index: srclib/apr/include/apr_network_io.h
===================================================================
RCS file: /home/cvspublic/apr/include/apr_network_io.h,v
retrieving revision 1.136
diff -u -b -B -r1.136 apr_network_io.h
--- srclib/apr/include/apr_network_io.h	1 Jan 2003 00:01:45 -0000	1.136
+++ srclib/apr/include/apr_network_io.h	3 Feb 2003 09:26:50 -0000
@@ -821,6 +821,14 @@
 #endif
 
 /**
+ * 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);
+
+/**
  * Return the protocol of the socket.
  * @param sock The socket to query.
  * @param protocol The returned protocol (e.g., APR_PROTO_TCP).
Index: srclib/apr/network_io/os2/sockets.c
===================================================================
RCS file: /home/cvspublic/apr/network_io/os2/sockets.c,v
retrieving revision 1.63
diff -u -b -B -r1.63 sockets.c
--- srclib/apr/network_io/os2/sockets.c	6 Jan 2003 23:44:34 -0000	1.63
+++ srclib/apr/network_io/os2/sockets.c	3 Feb 2003 09:26:50 -0000
@@ -104,6 +104,12 @@
     (*new)->remote_addr->pool = p;
 }
 
+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_protocol_get(apr_socket_t *sock, int *protocol)
 {
     *protocol = sock->protocol;
Index: srclib/apr/network_io/unix/sockets.c
===================================================================
RCS file: /home/cvspublic/apr/network_io/unix/sockets.c,v
retrieving revision 1.107
diff -u -b -B -r1.107 sockets.c
--- srclib/apr/network_io/unix/sockets.c	6 Jan 2003 23:44:35 -0000	1.107
+++ srclib/apr/network_io/unix/sockets.c	3 Feb 2003 09:26:50 -0000
@@ -104,6 +104,12 @@
     (*new)->remote_addr->pool = p;
 }
 
+apr_status_t apr_socket_type_get(apr_socket_t *sock, int *type)
+{
+    *type = sock->type;
+    return APR_SUCCESS;
+}
+
 apr_status_t apr_socket_protocol_get(apr_socket_t *sock, int *protocol)
 {
     *protocol = sock->protocol;
Index: srclib/apr/network_io/win32/sockets.c
===================================================================
RCS file: /home/cvspublic/apr/network_io/win32/sockets.c,v
retrieving revision 1.95
diff -u -b -B -r1.95 sockets.c
--- srclib/apr/network_io/win32/sockets.c	6 Jan 2003 23:44:36 -0000	1.95
+++ srclib/apr/network_io/win32/sockets.c	3 Feb 2003 09:26:50 -0000
@@ -95,6 +95,12 @@
     (*new)->remote_addr->pool = p;
 }
 
+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_protocol_get(apr_socket_t *sock,
                                                   int *protocol)
 {

--------------------------------------------------------------------------------
Philippe M. Chiasson /gozer\@(cpan|ectoplasm)\.org/ 88C3A5A5
(122FF51B/C634E37B)
http://gozer.ectoplasm.org/    F9BF E0C2 480E 7680 1AE5 3631 CB32 A107
88C3 A5A5
Q: It is impossible to make anything foolproof because fools are so
ingenious.
perl
-e'$$=\${gozer};{$_=unpack(P7,pack(L,$$));/^JAm_pH\n$/&&print||$$++&&redo}'


Mime
View raw message