summaryrefslogtreecommitdiff
path: root/lib/Socket.cc
diff options
context:
space:
mode:
authorPixel <Pixel>2001-11-30 00:03:10 +0000
committerPixel <Pixel>2001-11-30 00:03:10 +0000
commit68aeaf14ea2bc388b3d3c5d195fd3f5e983576c0 (patch)
treee776a0f936b7413b184ce34e205f4aca27f62b62 /lib/Socket.cc
parent23d91060b557f77fc37e629a168ca810cd66a364 (diff)
Debugging...
Diffstat (limited to 'lib/Socket.cc')
-rw-r--r--lib/Socket.cc14
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/Socket.cc b/lib/Socket.cc
index d3d7c19..f35bb72 100644
--- a/lib/Socket.cc
+++ b/lib/Socket.cc
@@ -122,3 +122,17 @@ Socket Socket::Accept(void) throw (GeneralException) {
return Socket(h);
}
}
+
+int Socket::GetPort() {
+ int r;
+ struct sockaddr_in localsocketaddr;
+ socklen_t locallen = sizeof(localsocketaddr);
+
+ if (getsockname(GetHandle(), (struct sockaddr *) &localsocketaddr, &locallen)) {
+ return -1;
+ }
+
+ r = ntohs(localsocketaddr.sin_port);
+
+ return r;
+}