summaryrefslogtreecommitdiff
path: root/test/server.c
diff options
context:
space:
mode:
authorbjh <bjh@13f79535-47bb-0310-9956-ffa450edef68>1999-10-24 05:59:17 +0000
committerbjh <bjh@13f79535-47bb-0310-9956-ffa450edef68>1999-10-24 05:59:17 +0000
commit6ca6daa435ede237dc98af223c39a76c71774884 (patch)
tree24cdbabad2718453a72a398890493f69ef642bf2 /test/server.c
parent133ba67098f7007c6e7dbcf54c8ce96e51549eda (diff)
downloadlibapr-6ca6daa435ede237dc98af223c39a76c71774884.tar.gz
Enhancements for APR network_io. Adds separate local/remote access methods for
a socket's port, IP address and sockaddr_in. Updates for Apache code to use these, allowing the correct IP address of clients to be logged. git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@59413 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'test/server.c')
-rw-r--r--test/server.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/test/server.c b/test/server.c
index da1a85229..20f162602 100644
--- a/test/server.c
+++ b/test/server.c
@@ -69,6 +69,8 @@ int main(int argc, char *argv[])
ap_pollfd_t *sdset;
char datasend[STRLEN];
char datarecv[STRLEN] = "Recv data test";
+ char *local_ipaddr, *remote_ipaddr;
+ ap_uint32_t local_port, remote_port;
fprintf(stdout, "Creating context.......");
if (ap_create_context(&context, NULL) != APR_SUCCESS) {
@@ -93,7 +95,7 @@ int main(int argc, char *argv[])
fprintf(stdout, "OK\n");
fprintf(stdout, "\tServer: Setting port for socket.......");
- if (ap_setport(sock, 8021) != APR_SUCCESS) {
+ if (ap_set_local_port(sock, 8021) != APR_SUCCESS) {
ap_close_socket(sock);
fprintf(stderr, "Couldn't set the port correctly\n");
exit(-1);
@@ -143,6 +145,12 @@ int main(int argc, char *argv[])
}
fprintf(stdout, "OK\n");
+ ap_get_remote_ipaddr(&remote_ipaddr, sock2);
+ ap_get_remote_port(&remote_port, sock2);
+ ap_get_local_ipaddr(&local_ipaddr, sock2);
+ ap_get_local_port(&local_port, sock2);
+ fprintf(stdout, "\tServer socket: %s:%u -> %s:%u\n", local_ipaddr, local_port, remote_ipaddr, remote_port);
+
length = STRLEN;
fprintf(stdout, "\tServer: Trying to recv data from socket.......");
if (ap_recv(sock2, datasend, &length) != APR_SUCCESS) {