#include <netui.h>
Definition at line 31 of file netui.h.
Definition at line 65 of file netui.cpp.
References bindFd(), VsnetOSS::close_socket(), COUT, NONBLOCKING_CONNECT, VsnetOSS::set_blocking(), VsnetOSS::socket(), SOCKET_ERROR, and static_initNetwork().
Referenced by createServerSocket(), NetUITCP::createSocket(), NetUIUDP::createSocket(), and VsnetHTTPSocket::reopenConnection().
70 if ( ( local_fd =
VsnetOSS::socket( PF_INET, isTCP ? SOCK_STREAM : SOCK_DGRAM, 0 ) ) == -1 ) {
71 COUT<<
"Could not create socket"<<std::endl;
75 COUT<<
"Connecting to "<<inet_ntoa( remote_ip.sin_addr )<<
" on port "<<ntohs( remote_ip.sin_port )<<std::endl;
83 #if defined (_WIN32) && !defined (__CYGWIN__)
84 if (::connect( local_fd, (sockaddr*) &remote_ip,
sizeof (
struct sockaddr) ) ==
SOCKET_ERROR)
86 if (::connect( local_fd, (sockaddr*) &remote_ip,
sizeof (
struct sockaddr) ) < 0)
89 #if defined (_WIN32) && !defined (__CYGWIN__)
90 int lasterr = WSAGetLastError();
91 if (lasterr != WSAEINPROGRESS && lasterr != WSAEWOULDBLOCK)
93 if (errno != EINPROGRESS && errno != EWOULDBLOCK)
96 perror(
"Can't connect to server " );
103 if ( !
bindFd( local_fd, remote_ip ) ) {
104 perror(
"Can't bind socket" );
Definition at line 111 of file netui.cpp.
References VsnetOSS::close_socket(), COUT, createClientSocket(), VsnetOSS::socket(), SOCKET_ERROR, and static_initNetwork().
Referenced by NetUITCP::createServerSocket(), and NetUIUDP::createServerSocket().
119 COUT<<
"Could not create socket"<<std::endl;
123 char *buf = (
char*) &newval;
124 setsockopt( local_fd, SOL_SOCKET, SO_REUSEADDR, buf,
sizeof (
int) );
127 COUT<<
"Bind on "<<ntohl( local_ip.sin_addr.s_addr )<<
", port "
128 <<ntohs( local_ip.sin_port )<<std::endl;
129 if (bind( local_fd, (sockaddr*) &local_ip,
sizeof (
struct sockaddr_in) ) ==
SOCKET_ERROR) {
130 perror(
"Problem binding socket" );
134 COUT<<
"Accepting max : "<<SOMAXCONN<<std::endl;
136 perror(
"Problem listening on socket" );
AddressIP NetUIBase::lookupHost |
( |
const char * |
host, |
|
|
unsigned short |
port |
|
) |
| |
|
static |
Definition at line 28 of file netui.cpp.
References COUT, VsnetOSS::inet_aton(), VsnetOSS::memcpy(), and static_initNetwork().
Referenced by NetUITCP::createServerSocket(), NetUIUDP::createServerSocket(), NetUITCP::createSocket(), NetUIUDP::createSocket(), remoteIPFromURI(), and NetClient::synchronizeTime().
33 memset( &remote_ip, 0,
sizeof (
AddressIP) );
35 struct hostent *he = NULL;
37 if (host[0] < 48 || host[0] > 57) {
38 COUT<<
"Resolving host name... ";
39 if ( ( he = gethostbyname( host ) ) == NULL ) {
40 cerr<<
"Could not resolve hostname"<<std::endl;
43 memcpy( &remote_ip.sin_addr.s_addr, he->h_addr_list[0], he->h_length );
44 cerr<<
"found : "<<inet_ntoa( remote_ip.sin_addr )<<std::endl;
46 COUT<<
"Error inet_aton"<<std::endl;
50 remote_ip.sin_port = htons( port );
51 remote_ip.sin_family = AF_INET;
The documentation for this class was generated from the following files: