From 68aeaf14ea2bc388b3d3c5d195fd3f5e983576c0 Mon Sep 17 00:00:00 2001 From: Pixel Date: Fri, 30 Nov 2001 00:03:10 +0000 Subject: Debugging... --- lib/Socket.cc | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'lib/Socket.cc') 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; +} -- cgit v1.2.3