- support msgids in charsets other than C and languages other than English
(based on patch by Stefan Kowski)
- added wxMicroSleep() and wxMilliSleep() replacing deprecated wxUsleep()
+- basic UDP sockets support (Lenny Maiorani)
All (GUI):
GSOCK_INVPORT,
GSOCK_WOULDBLOCK,
GSOCK_TIMEDOUT,
- GSOCK_MEMERR
+ GSOCK_MEMERR,
+ GSOCK_OPTERR,
} GSocketError;
/* See below for an explanation on how events work.
*/
GSocketEventFlags GSocket_Select(GSocket *socket, GSocketEventFlags flags);
+GSocketError GSocket_GetSockOpt(GSocket *socket, int level, int optname,
+ void *optval, int *optlen);
+
+GSocketError GSocket_SetSockOpt(GSocket *socket, int level, int optname,
+ const void *optval, int optlen);
+
+void GSocket_Streamed(GSocket *socket);
+void GSocket_Unstreamed(GSocket *socket);
/* Attributes */
void SetFlags(wxSocketFlags flags);
void SetTimeout(long seconds);
+ bool GetOption(int level, int optname, void *optval, int *optlen);
+ bool SetOption(int level, int optname, const void *optval, int optlen);
+ inline wxUint32 GetLastIOSize() const { return m_lcount; };
+
// event handling
void *GetClientData() const { return m_clientData; }
void SetClientData(void *data) { m_clientData = data; }
GSOCK_LOST_FLAG);
}
+
bool wxSocketBase::WaitForWrite(long seconds, long milliseconds)
{
return _Wait(seconds, milliseconds, GSOCK_OUTPUT_FLAG);
return _Wait(seconds, milliseconds, GSOCK_CONNECTION_FLAG);
}
+bool wxSocketBase::GetOption(int level, int optname, void *optval, int *optlen)
+{
+ if (GSocket_GetSockOpt(m_socket, level, optname, optval, optlen)
+ != GSOCK_NOERROR)
+ {
+ return FALSE;
+ }
+ return TRUE;
+}
+
+bool wxSocketBase::SetOption(int level, int optname, const void *optval,
+ int optlen)
+{
+ if (GSocket_SetSockOpt(m_socket, level, optname, optval, optlen)
+ != GSOCK_NOERROR)
+ {
+ return FALSE;
+ }
+ return TRUE;
+}
+
// ==========================================================================
// wxSocketClient
// ==========================================================================
m_socket = GSocket_new();
if(!m_socket)
+ {
+ wxASSERT_MSG( 0, _T("datagram socket not new'd") );
return;
-
+ }
// Setup the socket as non connection oriented
+ GSocket_Unstreamed(m_socket);
GSocket_SetLocal(m_socket, addr.GetAddress());
if( GSocket_SetNonOriented(m_socket) != GSOCK_NOERROR )
{
}
}
+GSocketError GSocket_GetSockOpt(GSocket *socket, int level, int optname,
+ void *optval, int *optlen)
+{
+ if (getsockopt(socket->m_fd, level, optname, optval, optlen) == 0)
+ {
+ return GSOCK_NOERROR;
+ }
+ return GSOCK_OPTERR;
+}
+
+GSocketError GSocket_SetSockOpt(GSocket *socket, int level, int optname,
+ const void *optval, int optlen)
+{
+ if (setsockopt(socket->m_fd, level, optname, optval, optlen) == 0)
+ {
+ return GSOCK_NOERROR;
+ }
+ return GSOCK_OPTERR;
+}
+
+void GSocket_Streamed(GSocket *socket)
+{
+ socket->m_stream = TRUE;
+}
+
+void GSocket_Unstreamed(GSocket *socket)
+{
+ socket->m_stream = FALSE;
+}
+
/* Internals (IO) */
/* _GSocket_Input_Timeout:
}
address->m_family = GSOCK_INET;
- address->m_realfamily = PF_INET;
+ address->m_realfamily = AF_INET;
((struct sockaddr_in *)address->m_addr)->sin_family = AF_INET;
((struct sockaddr_in *)address->m_addr)->sin_addr.s_addr = INADDR_ANY;
}
}
+GSocketError GSocket_GetSockOpt(GSocket *socket, int level, int optname,
+ void *optval, int *optlen)
+{
+ if (getsockopt(socket->m_fd, level, optname, optval, optlen) == 0)
+ {
+ return GSOCK_NOERROR;
+ }
+ return GSOCK_OPTERR;
+}
+
+GSocketError GSocket_SetSockOpt(GSocket *socket, int level, int optname,
+ const void *optval, int optlen)
+{
+ if (setsockopt(socket->m_fd, level, optname, optval, optlen) == 0)
+ {
+ return GSOCK_NOERROR;
+ }
+ return GSOCK_OPTERR;
+}
+
+void GSocket_Streamed(GSocket *socket)
+{
+ socket->m_stream = TRUE;
+}
+
+void GSocket_Unstreamed(GSocket *socket)
+{
+ socket->m_stream = FALSE;
+}
#define CALL_CALLBACK(socket, event) { \
_GSocket_Disable(socket, event); \