projects
/
wxWidgets.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
compilation fix for GTK+ 2.0
[wxWidgets.git]
/
src
/
unix
/
gsocket.cpp
diff --git
a/src/unix/gsocket.cpp
b/src/unix/gsocket.cpp
index 81c6a62fad8f6113b2ae46536be63c81aa850172..d7bb9362d30833b9dbde588d237e21223ab0a43a 100644
(file)
--- a/
src/unix/gsocket.cpp
+++ b/
src/unix/gsocket.cpp
@@
-87,6
+87,10
@@
int _System bsdselect(int,
int _System soclose(int);
# endif
#endif
int _System soclose(int);
# endif
#endif
+#ifdef __EMX__
+#include <sys/select.h>
+#endif
+
#include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
@@
-113,6
+117,12
@@
int _System soclose(int);
# endif
#endif
# endif
#endif
+#else
+ /* undefine for OSX - its really an int */
+# ifdef __DARWIN__
+# undef SOCKLEN_T
+# define SOCKLEN_T int
+# endif
#endif /* SOCKLEN_T */
/*
#endif /* SOCKLEN_T */
/*
@@
-164,7
+174,7
@@
int _System soclose(int);
/* Table of GUI-related functions. We must call them indirectly because
* of wxBase and GUI separation: */
/* Table of GUI-related functions. We must call them indirectly because
* of wxBase and GUI separation: */
-static
struct
GSocketGUIFunctionsTable *gs_gui_functions;
+static GSocketGUIFunctionsTable *gs_gui_functions;
class GSocketGUIFunctionsTableNull: public GSocketGUIFunctionsTable
{
class GSocketGUIFunctionsTableNull: public GSocketGUIFunctionsTable
{
@@
-200,7
+210,7
@@
void GSocketGUIFunctionsTableNull::Disable_Events(GSocket *socket)
{}
/* Global initialisers */
{}
/* Global initialisers */
-void GSocket_SetGUIFunctions(
struct
GSocketGUIFunctionsTable *guifunc)
+void GSocket_SetGUIFunctions(GSocketGUIFunctionsTable *guifunc)
{
gs_gui_functions = guifunc;
}
{
gs_gui_functions = guifunc;
}
@@
-209,7
+219,7
@@
int GSocket_Init(void)
{
if (!gs_gui_functions)
{
{
if (!gs_gui_functions)
{
- static
class
GSocketGUIFunctionsTableNull table;
+ static GSocketGUIFunctionsTableNull table;
gs_gui_functions = &table;
}
if ( !gs_gui_functions->OnInit() )
gs_gui_functions = &table;
}
if ( !gs_gui_functions->OnInit() )
@@
-240,13
+250,14
@@
GSocket::GSocket()
m_local = NULL;
m_peer = NULL;
m_error = GSOCK_NOERROR;
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_gui_dependent = NULL;
- m_non_blocking = FALSE;
+ m_non_blocking = false;
+ m_reusable = false;
m_timeout = 10*60*1000;
/* 10 minutes * 60 sec * 1000 millisec */
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 */
assert(gs_gui_functions);
/* Per-socket GUI-specific initialization */
@@
-456,8
+467,8
@@
GSocketError GSocket::SetServer()
}
/* Initialize all fields */
}
/* 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);
/* Create the socket */
m_fd = socket(m_local->m_realfamily, SOCK_STREAM, 0);
@@
-467,11
+478,7
@@
GSocketError GSocket::SetServer()
m_error = GSOCK_IOERR;
return GSOCK_IOERR;
}
m_error = GSOCK_IOERR;
return GSOCK_IOERR;
}
-#if defined(__EMX__) || defined(__VISAGECPP__)
- ioctl(m_fd, FIONBIO, (char*)&arg, sizeof(arg));
-#else
ioctl(m_fd, FIONBIO, &arg);
ioctl(m_fd, FIONBIO, &arg);
-#endif
gs_gui_functions->Enable_Events(this);
/* allow a socket to re-bind if the socket is in the TIME_WAIT
gs_gui_functions->Enable_Events(this);
/* allow a socket to re-bind if the socket is in the TIME_WAIT
@@
-542,7
+549,7
@@
GSocket *GSocket::WaitConnection()
/* Wait for a connection (with timeout) */
if (Input_Timeout() == GSOCK_TIMEDOUT)
{
/* Wait for a connection (with timeout) */
if (Input_Timeout() == GSOCK_TIMEDOUT)
{
-
GSocket_destroy(connection)
;
+
delete connection
;
/* m_error set by _GSocket_Input_Timeout */
return NULL;
}
/* m_error set by _GSocket_Input_Timeout */
return NULL;
}
@@
-556,19
+563,19
@@
GSocket *GSocket::WaitConnection()
else
m_error = GSOCK_IOERR;
else
m_error = GSOCK_IOERR;
-
GSocket_destroy(connection)
;
+
delete connection
;
return NULL;
}
/* Initialize all fields */
return NULL;
}
/* 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();
if (!connection->m_peer)
{
/* Setup the peer address field */
connection->m_peer = GAddress_new();
if (!connection->m_peer)
{
-
GSocket_destroy(connection)
;
+
delete connection
;
m_error = GSOCK_MEMERR;
return NULL;
}
m_error = GSOCK_MEMERR;
return NULL;
}
@@
-576,7
+583,7
@@
GSocket *GSocket::WaitConnection()
if (err != GSOCK_NOERROR)
{
GAddress_destroy(connection->m_peer);
if (err != GSOCK_NOERROR)
{
GAddress_destroy(connection->m_peer);
-
GSocket_destroy(connection)
;
+
delete connection
;
m_error = err;
return NULL;
}
m_error = err;
return NULL;
}
@@
-590,14
+597,14
@@
GSocket *GSocket::WaitConnection()
return connection;
}
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) {
{
/* 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 */
}
/* Client specific parts */
@@
-649,8
+656,8
@@
GSocketError GSocket::Connect(GSocketStream stream)
/* Streamed or dgram socket? */
m_stream = (stream == GSOCK_STREAMED);
/* 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,
/* Create the socket */
m_fd = socket(m_peer->m_realfamily,
@@
-708,7
+715,7
@@
GSocketError GSocket::Connect(GSocketStream stream)
*/
if ((err == EINPROGRESS) && (m_non_blocking))
{
*/
if ((err == EINPROGRESS) && (m_non_blocking))
{
- m_establishing =
TRUE
;
+ m_establishing =
true
;
m_error = GSOCK_WOULDBLOCK;
return GSOCK_WOULDBLOCK;
}
m_error = GSOCK_WOULDBLOCK;
return GSOCK_WOULDBLOCK;
}
@@
-756,8
+763,8
@@
GSocketError GSocket::SetNonOriented()
}
/* Initialize all fields */
}
/* 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);
/* Create the socket */
m_fd = socket(m_local->m_realfamily, SOCK_DGRAM, 0);
@@
-913,7
+920,7
@@
GSocketEventFlags GSocket::Select(GSocketEventFlags flags)
/* Do not use a static struct, Linux can garble it */
tv.tv_sec = m_timeout / 1000;
/* Do not use a static struct, Linux can garble it */
tv.tv_sec = m_timeout / 1000;
- tv.tv_usec = (m_timeout % 1000)
/
1000;
+ tv.tv_usec = (m_timeout % 1000)
*
1000;
FD_ZERO(&readfds);
FD_ZERO(&writefds);
FD_ZERO(&readfds);
FD_ZERO(&writefds);
@@
-931,7
+938,7
@@
GSocketEventFlags GSocket::Select(GSocketEventFlags flags)
*/
if ((m_detected & GSOCK_LOST_FLAG) != 0)
{
*/
if ((m_detected & GSOCK_LOST_FLAG) != 0)
{
- m_establishing =
FALSE
;
+ m_establishing =
false
;
return (GSOCK_LOST_FLAG & flags);
}
return (GSOCK_LOST_FLAG & flags);
}
@@
-962,7
+969,7
@@
GSocketEventFlags GSocket::Select(GSocketEventFlags flags)
else
{
m_detected = GSOCK_LOST_FLAG;
else
{
m_detected = GSOCK_LOST_FLAG;
- m_establishing =
FALSE
;
+ m_establishing =
false
;
/* LOST event: Abort any further processing */
return (GSOCK_LOST_FLAG & flags);
/* LOST event: Abort any further processing */
return (GSOCK_LOST_FLAG & flags);
@@
-978,7
+985,7
@@
GSocketEventFlags GSocket::Select(GSocketEventFlags flags)
int error;
SOCKLEN_T len = sizeof(error);
int error;
SOCKLEN_T len = sizeof(error);
- m_establishing =
FALSE
;
+ m_establishing =
false
;
getsockopt(m_fd, SOL_SOCKET, SO_ERROR, (void*)&error, &len);
getsockopt(m_fd, SOL_SOCKET, SO_ERROR, (void*)&error, &len);
@@
-1004,7
+1011,7
@@
GSocketEventFlags GSocket::Select(GSocketEventFlags flags)
/* Check for exceptions and errors (is this useful in Unices?) */
if (FD_ISSET(m_fd, &exceptfds))
{
/* 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_detected = GSOCK_LOST_FLAG;
/* LOST event: Abort any further processing */
@@
-1029,7
+1036,7
@@
GSocketEventFlags GSocket::Select(GSocketEventFlags flags)
* Sets the socket to non-blocking mode. All IO calls will return
* immediately.
*/
* 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);
{
assert(this);
@@
-1131,7
+1138,7
@@
void GSocket::UnsetCallback(GSocketEventFlags flags)
GSocketError GSocket::GetSockOpt(int level, int optname,
void *optval, int *optlen)
{
GSocketError GSocket::GetSockOpt(int level, int optname,
void *optval, int *optlen)
{
- if (getsockopt(m_fd, level, optname, optval, optlen) == 0)
+ if (getsockopt(m_fd, level, optname, optval,
(SOCKLEN_T*)
optlen) == 0)
{
return GSOCK_NOERROR;
}
{
return GSOCK_NOERROR;
}
@@
-1149,7
+1156,7
@@
GSocketError GSocket::SetSockOpt(int level, int optname,
}
#define CALL_CALLBACK(socket, event) { \
}
#define CALL_CALLBACK(socket, event) { \
- socket->Disable(event); \
+ socket->Disable(event);
\
if (socket->m_cbacks[event]) \
socket->m_cbacks[event](socket, event, socket->m_data[event]); \
}
if (socket->m_cbacks[event]) \
socket->m_cbacks[event](socket, event, socket->m_data[event]); \
}
@@
-1356,7
+1363,7
@@
void GSocket::Detected_Read()
*/
if ((m_detected & GSOCK_LOST_FLAG) != 0)
{
*/
if ((m_detected & GSOCK_LOST_FLAG) != 0)
{
- m_establishing =
FALSE
;
+ m_establishing =
false
;
CALL_CALLBACK(this, GSOCK_LOST);
Shutdown();
CALL_CALLBACK(this, GSOCK_LOST);
Shutdown();
@@
-1388,7
+1395,7
@@
void GSocket::Detected_Write()
*/
if ((m_detected & GSOCK_LOST_FLAG) != 0)
{
*/
if ((m_detected & GSOCK_LOST_FLAG) != 0)
{
- m_establishing =
FALSE
;
+ m_establishing =
false
;
CALL_CALLBACK(this, GSOCK_LOST);
Shutdown();
CALL_CALLBACK(this, GSOCK_LOST);
Shutdown();
@@
-1400,7
+1407,7
@@
void GSocket::Detected_Write()
int error;
SOCKLEN_T len = sizeof(error);
int error;
SOCKLEN_T len = sizeof(error);
- m_establishing =
FALSE
;
+ m_establishing =
false
;
getsockopt(m_fd, SOL_SOCKET, SO_ERROR, (void*)&error, &len);
getsockopt(m_fd, SOL_SOCKET, SO_ERROR, (void*)&error, &len);
@@
-1698,7
+1705,11
@@
GSocketError GAddress_INET_SetPortName(GAddress *address, const char *port,
return GSOCK_INVPORT;
}
return GSOCK_INVPORT;
}
+#if defined(__WXPM__) && defined(__EMX__)
+ se = getservbyname(port, (char*)protocol);
+#else
se = getservbyname(port, protocol);
se = getservbyname(port, protocol);
+#endif
if (!se)
{
/* the cast to int suppresses compiler warnings about subscript having the
if (!se)
{
/* the cast to int suppresses compiler warnings about subscript having the