diff options
author | Adam Tkac <atkac@redhat.com> | 2008-12-10 16:42:33 +0000 |
---|---|---|
committer | Adam Tkac <atkac@redhat.com> | 2008-12-10 16:42:33 +0000 |
commit | be4c3acee78f27f979849677c52b3c5d9dc5acb0 (patch) | |
tree | 0ca4414e81f55d3ccf2dd0882fbda73fdc85ba54 /common/network | |
parent | 3a209d5f5a2dfee5d329c5909108e6c64e3c7187 (diff) | |
download | tigervnc-be4c3acee78f27f979849677c52b3c5d9dc5acb0.tar.gz tigervnc-be4c3acee78f27f979849677c52b3c5d9dc5acb0.zip |
[Layout] Added os/net.[ch]. They will include wrappers for missing IPv6
capabilities and should hide common networking related differences
between OSs
[Port] Implement IPv4-only version of inet_ntop for OSs which doesn't have it
git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@3369 3789f03b-4d11-0410-bbf8-ca57d06f2519
Diffstat (limited to 'common/network')
-rw-r--r-- | common/network/TcpSocket.cxx | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/common/network/TcpSocket.cxx b/common/network/TcpSocket.cxx index 4a37d01c..7ceff0b0 100644 --- a/common/network/TcpSocket.cxx +++ b/common/network/TcpSocket.cxx @@ -24,9 +24,6 @@ //#include <io.h> #include <winsock2.h> #define errorNumber WSAGetLastError() -#ifndef VNC_SOCKLEN_T -#define VNC_SOCKLEN_T int -#endif #else #define errorNumber errno #define closesocket close @@ -45,6 +42,7 @@ #include <stdlib.h> #include <network/TcpSocket.h> +#include <os/net.h> #include <rfb/util.h> #include <rfb/LogWriter.h> @@ -124,7 +122,7 @@ TcpSocket::TcpSocket(const char *host, int port) { int sock, err, result, family; vnc_sockaddr_t sa; - VNC_SOCKLEN_T salen; + socklen_t salen; #ifdef HAVE_GETADDRINFO struct addrinfo *ai, *current, hints; #endif @@ -233,7 +231,7 @@ TcpSocket::~TcpSocket() { char* TcpSocket::getMyAddress() { struct sockaddr_in info; struct in_addr addr; - VNC_SOCKLEN_T info_size = sizeof(info); + socklen_t info_size = sizeof(info); getsockname(getFd(), (struct sockaddr *)&info, &info_size); memcpy(&addr, &info.sin_addr, sizeof(addr)); @@ -263,7 +261,7 @@ char* TcpSocket::getMyEndpoint() { char* TcpSocket::getPeerAddress() { struct sockaddr_in info; struct in_addr addr; - VNC_SOCKLEN_T info_size = sizeof(info); + socklen_t info_size = sizeof(info); getpeername(getFd(), (struct sockaddr *)&info, &info_size); memcpy(&addr, &info.sin_addr, sizeof(addr)); @@ -278,7 +276,7 @@ char* TcpSocket::getPeerAddress() { int TcpSocket::getPeerPort() { struct sockaddr_in info; - VNC_SOCKLEN_T info_size = sizeof(info); + socklen_t info_size = sizeof(info); getpeername(getFd(), (struct sockaddr *)&info, &info_size); return ntohs(info.sin_port); @@ -296,7 +294,7 @@ char* TcpSocket::getPeerEndpoint() { bool TcpSocket::sameMachine() { struct sockaddr_in peeraddr, myaddr; - VNC_SOCKLEN_T addrlen = sizeof(struct sockaddr_in); + socklen_t addrlen = sizeof(struct sockaddr_in); getpeername(getFd(), (struct sockaddr *)&peeraddr, &addrlen); getsockname(getFd(), (struct sockaddr *)&myaddr, &addrlen); @@ -324,21 +322,21 @@ bool TcpSocket::enableNagles(int sock, bool enable) { bool TcpSocket::isSocket(int sock) { struct sockaddr_in info; - VNC_SOCKLEN_T info_size = sizeof(info); + socklen_t info_size = sizeof(info); return getsockname(sock, (struct sockaddr *)&info, &info_size) >= 0; } bool TcpSocket::isConnected(int sock) { struct sockaddr_in info; - VNC_SOCKLEN_T info_size = sizeof(info); + socklen_t info_size = sizeof(info); return getpeername(sock, (struct sockaddr *)&info, &info_size) >= 0; } int TcpSocket::getSockPort(int sock) { struct sockaddr_in info; - VNC_SOCKLEN_T info_size = sizeof(info); + socklen_t info_size = sizeof(info); if (getsockname(sock, (struct sockaddr *)&info, &info_size) < 0) return 0; return ntohs(info.sin_port); |