GAddress *GetPeer();
GSocketError SetServer();
GSocket *WaitConnection();
- int SetReusable() { return 0; }
+ bool SetReusable() { return false; }
GSocketError SetNonOriented();
GSocketError Connect(GSocketStream stream);
int Read(char *buffer, int size);
int Write(const char *buffer, int size);
GSocketEventFlags Select(GSocketEventFlags flags);
- void SetNonBlocking(int non_block);
+ void SetNonBlocking(bool non_block);
void SetTimeout(unsigned long millisec);
GSocketError WXDLLIMPEXP_NET GetError();
void SetCallback(GSocketEventFlags flags,
GAddress *m_peer;
GSocketError m_error;
- int m_non_blocking;
- int m_server;
- int m_stream;
- int m_oriented;
+ bool m_non_blocking;
+ bool m_server;
+ bool m_stream;
+ bool m_oriented;
unsigned long m_timeout;
/* Callbacks */
GSocketEventFlags m_detected;
GSocketCallback m_cbacks[GSOCK_MAX_EVENT];
char *m_data[GSOCK_MAX_EVENT];
- int m_takesEvents ;
+ bool m_takesEvents ;
};
#include "wx/msw/wrapwin.h"
-#ifndef TRUE
-#define TRUE 1
-#endif
-
-#ifndef FALSE
-#define FALSE 0
-#endif
-
class GSocketGUIFunctionsTableConcrete: public GSocketGUIFunctionsTable
{
public:
GAddress *GetPeer();
GSocketError SetServer();
GSocket *WaitConnection();
- int SetReusable();
+ bool SetReusable();
GSocketError Connect(GSocketStream stream);
GSocketError SetNonOriented();
int Read(char *buffer, int size);
GSocketError m_error;
/* Attributes */
- int m_non_blocking;
- int m_server;
- int m_stream;
- int m_establishing;
- int m_reusable;
+ bool m_non_blocking;
+ bool m_server;
+ bool m_stream;
+ bool m_establishing;
+ bool m_reusable;
struct timeval m_timeout;
/* Callbacks */
#include "gsocket.h"
#endif
-#ifndef TRUE
-#define TRUE 1
-#endif
-
-#ifndef FALSE
-#define FALSE 0
-#endif
-
class GSocketGUIFunctionsTableConcrete: public GSocketGUIFunctionsTable
{
public:
GAddress *GetPeer();
GSocketError SetServer();
GSocket *WaitConnection();
- int SetReusable();
+ bool SetReusable();
GSocketError Connect(GSocketStream stream);
GSocketError SetNonOriented();
int Read(char *buffer, int size);
int Write(const char *buffer, int size);
GSocketEventFlags Select(GSocketEventFlags flags);
- void SetNonBlocking(int non_block);
+ void SetNonBlocking(bool non_block);
void SetTimeout(unsigned long millisec);
GSocketError WXDLLIMPEXP_NET GetError();
void SetCallback(GSocketEventFlags flags,
GAddress *m_peer;
GSocketError m_error;
- int m_non_blocking;
- int m_server;
- int m_stream;
- int m_establishing;
- int m_reusable;
+ bool m_non_blocking;
+ bool m_server;
+ bool m_stream;
+ bool m_establishing;
+ bool m_reusable;
unsigned long m_timeout;
/* Callbacks */
#ifdef __DARWIN__
#include <CoreServices/CoreServices.h>
- #ifndef FALSE
- #define FALSE 0
- #endif
- #ifndef TRUE
- #define TRUE 1
- #endif
#else
#include <MacHeaders.c>
#define OTUNIXERRORS 1
int GSocket_Init()
{
- return TRUE;
+ return 1;
}
-int GSocket_Verify_Inited() ;
-int GSocket_Verify_Inited()
+bool GSocket_Verify_Inited() ;
+bool GSocket_Verify_Inited()
{
OSStatus err ;
#if TARGET_CARBON
OTClientContextPtr clientcontext;
if ( gInetSvcRef )
- return TRUE ;
+ return true ;
InitOpenTransportInContext(kInitOTForApplicationMask, &clientcontext);
gOTInited = 1 ;
NULL, &err, clientcontext);
#else
if ( gInetSvcRef )
- return TRUE ;
+ return true ;
InitOpenTransport() ;
gOTInited = 1 ;
if ( gInetSvcRef == NULL || err != kOTNoError )
{
OTAssert("Could not open Inet Services", err == noErr);
- return FALSE ;
+ return false ;
}
gOTNotifierUPP = NewOTNotifyUPP( OTInetEventHandler ) ;
- return TRUE ;
+ return true ;
}
void GSocket_Cleanup()
{
int i;
- m_ok = (GSocket_Verify_Inited() != FALSE);
+ m_ok = GSocket_Verify_Inited();
m_endpoint = NULL ;
for (i=0;i<GSOCK_MAX_EVENT;i++)
m_local = NULL;
m_peer = NULL;
m_error = GSOCK_NOERROR;
- m_server = FALSE;
- m_stream = TRUE;
- m_non_blocking = FALSE;
+ m_server = false;
+ m_stream = true;
+ m_non_blocking = false;
m_timeout = 1*1000;
/* 10 sec * 1000 millisec */
- m_takesEvents = TRUE ;
+ m_takesEvents = true ;
m_mac_events = wxMacGetNotifierTable() ;
}
}
/* Initialize all fields */
- m_stream = TRUE;
- m_server = TRUE;
- m_oriented = TRUE;
+ m_stream = true;
+ m_server = true;
+ m_oriented = true;
// TODO
#if 0
}
/* Initialize all fields */
- connection->m_server = FALSE;
- connection->m_stream = TRUE;
- connection->m_oriented = TRUE;
+ connection->m_server = false;
+ connection->m_stream = true;
+ connection->m_oriented = true;
/* Setup the peer address field */
connection->m_peer = GAddress_new();
}
/* Initialize all fields */
- m_stream = FALSE;
- m_server = FALSE;
- m_oriented = FALSE;
+ m_stream = false;
+ m_server = false;
+ m_oriented = false;
/* Create the socket */
/* Streamed or dgram socket? */
m_stream = (stream == GSOCK_STREAMED);
- m_oriented = TRUE;
- m_server = FALSE;
+ m_oriented = true;
+ m_server = false;
/* Create the socket */
#if TARGET_CARBON
* Sets the socket to non-blocking mode. All IO calls will return
* immediately.
*/
-void GSocket::SetNonBlocking(int non_block)
+void GSocket::SetNonBlocking(bool non_block)
{
assert(this);
GSocketError _GAddress_translate_to(GAddress *address,
InetAddress *addr)
{
- if ( GSocket_Verify_Inited() == FALSE )
+ if ( !GSocket_Verify_Inited() )
return GSOCK_IOERR ;
memset(addr, 0 , sizeof(struct InetAddress));
OTInitInetAddress( addr , address->m_port , address->m_host ) ;
InetHostInfo hinfo ;
OSStatus ret ;
- if ( GSocket_Verify_Inited() == FALSE )
+ if ( !GSocket_Verify_Inited() )
return GSOCK_IOERR ;
assert(address != NULL);
GSocketError GAddress_INET_GetHostName(GAddress *address, char *hostname, size_t sbuf)
{
InetDomainName name ;
- if ( GSocket_Verify_Inited() == FALSE )
+ if ( !GSocket_Verify_Inited() )
return GSOCK_IOERR ;
assert(address != NULL);
{
OTResult state ;
- m_takesEvents = TRUE ;
+ m_takesEvents = true ;
state = OTGetEndpointState(m_endpoint);
{
void GSocket::Disable_Events()
{
- m_takesEvents = FALSE ;
+ m_takesEvents = false ;
}
/* _GSocket_Input_Timeout:
if ( !m_non_blocking )
{
UnsignedWide now , start ;
- short formerTakesEvents = m_takesEvents ;
+ bool formerTakesEvents = m_takesEvents ;
Microseconds(&start);
now = start ;
- m_takesEvents = FALSE ;
+ m_takesEvents = false ;
while( (now.hi * 4294967296.0 + now.lo) - (start.hi * 4294967296.0 + start.lo) < m_timeout * 1000.0 )
{
if ( !m_non_blocking )
{
UnsignedWide now , start ;
- short formerTakesEvents = m_takesEvents ;
+ bool formerTakesEvents = m_takesEvents ;
Microseconds(&start);
now = start ;
- m_takesEvents = FALSE ;
+ m_takesEvents = false ;
while( (now.hi * 4294967296.0 + now.lo) - (start.hi * 4294967296.0 + start.lo) < m_timeout * 1000.0 )
{
m_id[0] = -1;
m_id[1] = -1;
- return TRUE;
+ return true;
}
void GSocketGUIFunctionsTableConcrete::Destroy_Socket(GSocket *socket)
m_local = NULL;
m_peer = NULL;
m_error = GSOCK_NOERROR;
- m_server = FALSE;
- m_stream = TRUE;
+ m_server = false;
+ m_stream = true;
m_non_blocking = false;
m_timeout.tv_sec = 10 * 60; /* 10 minutes */
m_timeout.tv_usec = 0;
- m_establishing = FALSE;
- m_reusable = FALSE;
+ m_establishing = false;
+ m_reusable = false;
assert(gs_gui_functions);
/* Per-socket GUI-specific initialization */
}
/* Initialize all fields */
- m_server = TRUE;
- m_stream = TRUE;
+ m_server = true;
+ m_stream = true;
/* Create the socket */
m_fd = socket(m_local->m_realfamily, SOCK_STREAM, 0);
}
/* Initialize all fields */
- connection->m_server = FALSE;
- connection->m_stream = TRUE;
+ connection->m_server = false;
+ connection->m_stream = true;
/* Setup the peer address field */
connection->m_peer = GAddress_new();
* Returns TRUE if the flag was set correctly, FALSE if an error occured
* (ie, if the parameter was NULL)
*/
-int GSocket::SetReusable()
+bool GSocket::SetReusable()
{
/* socket must not be null, and must not be in use/already bound */
if (this && m_fd == INVALID_SOCKET) {
- m_reusable = TRUE;
- return TRUE;
+ m_reusable = true;
+ return true;
}
- return FALSE;
+ return false;
}
/* Client specific parts */
/* Streamed or dgram socket? */
m_stream = (stream == GSOCK_STREAMED);
- m_server = FALSE;
- m_establishing = FALSE;
+ m_server = false;
+ m_establishing = false;
/* Create the socket */
m_fd = socket(m_peer->m_realfamily,
*/
if ((err == WSAEWOULDBLOCK) && (m_non_blocking))
{
- m_establishing = TRUE;
+ m_establishing = true;
m_error = GSOCK_WOULDBLOCK;
return GSOCK_WOULDBLOCK;
}
}
/* Initialize all fields */
- m_stream = FALSE;
- m_server = FALSE;
+ m_stream = false;
+ m_server = false;
/* Create the socket */
m_fd = socket(m_local->m_realfamily, SOCK_DGRAM, 0);
*/
if ((m_detected & GSOCK_LOST_FLAG) != 0)
{
- m_establishing = FALSE;
+ m_establishing = false;
return (GSOCK_LOST_FLAG & flags);
}
else
{
m_detected = GSOCK_LOST_FLAG;
- m_establishing = FALSE;
+ m_establishing = false;
/* LOST event: Abort any further processing */
return (GSOCK_LOST_FLAG & flags);
int error;
SOCKLEN_T len = sizeof(error);
- m_establishing = FALSE;
+ m_establishing = false;
getsockopt(m_fd, SOL_SOCKET, SO_ERROR, (char*)&error, &len);
/* Check for exceptions and errors (is this useful in Unices?) */
if (FD_ISSET(m_fd, &exceptfds))
{
- m_establishing = FALSE;
+ m_establishing = false;
m_detected = GSOCK_LOST_FLAG;
/* LOST event: Abort any further processing */
m_id[0] = -1;
m_id[1] = -1;
- return TRUE;
+ return true;
}
void GSocketGUIFunctionsTableConcrete::Destroy_Socket(GSocket *socket)
m_local = NULL;
m_peer = NULL;
m_error = GSOCK_NOERROR;
- m_server = FALSE;
- m_stream = TRUE;
+ m_server = false;
+ m_stream = true;
m_gui_dependent = NULL;
- m_non_blocking = FALSE;
+ m_non_blocking = false;
m_timeout = 10*60*1000;
/* 10 minutes * 60 sec * 1000 millisec */
- m_establishing = FALSE;
+ m_establishing = false;
assert(gs_gui_functions);
/* Per-socket GUI-specific initialization */
}
/* Initialize all fields */
- m_stream = TRUE;
- m_server = TRUE;
+ m_stream = true;
+ m_server = true;
/* Create the socket */
m_fd = socket(m_local->m_realfamily, SOCK_STREAM, 0);
}
/* Initialize all fields */
- connection->m_server = FALSE;
- connection->m_stream = TRUE;
+ connection->m_server = false;
+ connection->m_stream = true;
/* Setup the peer address field */
connection->m_peer = GAddress_new();
return connection;
}
-int GSocket::SetReusable()
+bool GSocket::SetReusable()
{
/* socket must not be null, and must not be in use/already bound */
if (this && m_fd == INVALID_SOCKET) {
- m_reusable = TRUE;
- return TRUE;
+ m_reusable = true;
+ return true;
}
- return FALSE;
+ return false;
}
/* Client specific parts */
/* Streamed or dgram socket? */
m_stream = (stream == GSOCK_STREAMED);
- m_server = FALSE;
- m_establishing = FALSE;
+ m_server = false;
+ m_establishing = false;
/* Create the socket */
m_fd = socket(m_peer->m_realfamily,
*/
if ((err == EINPROGRESS) && (m_non_blocking))
{
- m_establishing = TRUE;
+ m_establishing = true;
m_error = GSOCK_WOULDBLOCK;
return GSOCK_WOULDBLOCK;
}
}
/* Initialize all fields */
- m_stream = FALSE;
- m_server = FALSE;
+ m_stream = false;
+ m_server = false;
/* Create the socket */
m_fd = socket(m_local->m_realfamily, SOCK_DGRAM, 0);
*/
if ((m_detected & GSOCK_LOST_FLAG) != 0)
{
- m_establishing = FALSE;
+ m_establishing = false;
return (GSOCK_LOST_FLAG & flags);
}
else
{
m_detected = GSOCK_LOST_FLAG;
- m_establishing = FALSE;
+ m_establishing = false;
/* LOST event: Abort any further processing */
return (GSOCK_LOST_FLAG & flags);
int error;
SOCKLEN_T len = sizeof(error);
- m_establishing = FALSE;
+ m_establishing = false;
getsockopt(m_fd, SOL_SOCKET, SO_ERROR, (void*)&error, &len);
/* Check for exceptions and errors (is this useful in Unices?) */
if (FD_ISSET(m_fd, &exceptfds))
{
- m_establishing = FALSE;
+ m_establishing = false;
m_detected = GSOCK_LOST_FLAG;
/* LOST event: Abort any further processing */
* Sets the socket to non-blocking mode. All IO calls will return
* immediately.
*/
-void GSocket::SetNonBlocking(int non_block)
+void GSocket::SetNonBlocking(bool non_block)
{
assert(this);
*/
if ((m_detected & GSOCK_LOST_FLAG) != 0)
{
- m_establishing = FALSE;
+ m_establishing = false;
CALL_CALLBACK(this, GSOCK_LOST);
Shutdown();
*/
if ((m_detected & GSOCK_LOST_FLAG) != 0)
{
- m_establishing = FALSE;
+ m_establishing = false;
CALL_CALLBACK(this, GSOCK_LOST);
Shutdown();
int error;
SOCKLEN_T len = sizeof(error);
- m_establishing = FALSE;
+ m_establishing = false;
getsockopt(m_fd, SOL_SOCKET, SO_ERROR, (void*)&error, &len);
m_id[0] = -1;
m_id[1] = -1;
- return TRUE;
+ return true;
}
void GSocketGUIFunctionsTableConcrete::Destroy_Socket(GSocket *socket)