summaryrefslogtreecommitdiff
path: root/src/ivysocket.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ivysocket.c')
-rw-r--r--src/ivysocket.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/ivysocket.c b/src/ivysocket.c
index 3fe723d..bf1b76c 100644
--- a/src/ivysocket.c
+++ b/src/ivysocket.c
@@ -406,6 +406,27 @@ char *SocketGetPeerHost (Client client )
return host->h_name;
}
+unsigned short int SocketGetLocalPort ( Client client )
+{
+ int err;
+ struct sockaddr_in name;
+ socklen_t len = sizeof(name);
+
+ if (!client)
+ return 0;
+
+ err = getsockname (client->fd, (struct sockaddr *)&name, &len );
+ if (err < 0 ) return 0;
+ return name.sin_port;;
+}
+unsigned short int SocketGetRemotePort ( Client client )
+{
+ if (!client)
+ return 0;
+
+ return client->from.sin_port;
+}
+
struct in_addr * SocketGetRemoteAddr (Client client )
{
return client ? &client->from.sin_addr : 0;