-void Server_OnRequest(wxSocketServer& server,
- wxSocketBase::wxRequestEvent evt,
- char *cdata);
-void Client_OnRequest(wxSocketBase& sock,
- wxSocketBase::wxRequestEvent evt,
- char *cdata);
+// All sockets will be created with the following flags
+#define SCKIPC_FLAGS (wxSOCKET_WAITALL)
+
+// headers needed for umask()
+#ifdef __UNIX_LIKE__
+ #include <sys/types.h>
+ #include <sys/stat.h>
+#endif // __UNIX_LIKE__
+
+// ----------------------------------------------------------------------------
+// private functions
+// ----------------------------------------------------------------------------
+
+// get the address object for the given server name, the caller must delete it
+static wxSockAddress *
+GetAddressFromName(const wxString& serverName, const wxString& host = wxEmptyString)
+{
+ // we always use INET sockets under non-Unix systems
+#if defined(__UNIX__) && !defined(__WINDOWS__) && !defined(__WXMAC__) && !defined(__WINE__)
+ // under Unix, if the server name looks like a path, create a AF_UNIX
+ // socket instead of AF_INET one
+ if ( serverName.Find(_T('/')) != wxNOT_FOUND )
+ {
+ wxUNIXaddress *addr = new wxUNIXaddress;
+ addr->Filename(serverName);
+
+ return addr;
+ }
+#endif // Unix/!Unix
+ {
+ wxIPV4address *addr = new wxIPV4address;
+ addr->Service(serverName);
+ if ( !host.empty() )
+ {
+ addr->Hostname(host);
+ }
+
+ return addr;
+ }
+}
+
+// --------------------------------------------------------------------------
+// wxTCPEventHandler stuff (private class)
+// --------------------------------------------------------------------------
+
+class wxTCPEventHandler : public wxEvtHandler
+{
+public:
+ wxTCPEventHandler() : wxEvtHandler() {}
+
+ void Client_OnRequest(wxSocketEvent& event);
+ void Server_OnRequest(wxSocketEvent& event);
+
+ DECLARE_EVENT_TABLE()
+ DECLARE_NO_COPY_CLASS(wxTCPEventHandler)
+};
+
+enum
+{
+ _CLIENT_ONREQUEST_ID = 1000,
+ _SERVER_ONREQUEST_ID
+};
+
+static wxTCPEventHandler *gs_handler = NULL;