17 #include "connectiontcpserver.h"
18 #include "connectiontcpclient.h"
19 #include "connectionhandler.h"
23 #include "mutexguard.h"
29 #if !defined( _WIN32 ) && !defined( _WIN32_WCE )
30 # include <netinet/in.h>
31 # include <arpa/nameser.h>
34 # include <arpa/inet.h>
35 # include <sys/socket.h>
37 # include <sys/select.h>
43 #elif defined( _WIN32_WCE )
44 # include <winsock2.h>
51 # include <sys/types.h>
59 const std::string& ip,
int port )
61 m_connectionHandler( ch )
89 struct sockaddr_in local;
90 local.sin_family = AF_INET;
91 local.sin_port = htons( m_port );
92 local.sin_addr.s_addr = m_server.empty() ? INADDR_ANY : inet_addr( m_server.c_str() );
93 memset( &(local.sin_zero),
'\0', 8 );
95 if( bind( m_socket, (
struct sockaddr*)&local,
sizeof(
struct sockaddr ) ) < 0 )
98 if( listen( m_socket, 10 ) < 0 )
109 if( m_cancel || m_socket < 0 || !m_connectionHandler )
115 if( !dataAvailable( timeout ) )
121 struct sockaddr_in they;
122 int sin_size =
sizeof(
struct sockaddr_in );
124 int newfd = accept( m_socket, (
struct sockaddr*)&they, &sin_size );
126 int newfd = accept( m_socket, (
struct sockaddr*)&they, (socklen_t*)&sin_size );
132 ntohs( they.sin_port ) );