// Declarations
// ==========================================================================
-#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
-#pragma implementation "socket.h"
-#endif
-
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#include "wx/sckaddr.h"
#include "wx/socket.h"
+#include "wx/stopwatch.h"
// DLL options compatibility check:
#include "wx/build.h"
public:
wxSocketState() : wxObject() {}
- DECLARE_NO_COPY_CLASS(wxSocketState)
+ DECLARE_NO_COPY_CLASS(wxSocketState)
};
// ==========================================================================
BTW, the main thread must not be stopped using sleep or block
on a semaphore (a bad idea in any case) or socket operations
will time out.
+
+ On the Mac side, Initialize() stores a pointer to the CFRunLoop for
+ the main thread. Because secondary threads do not have run loops,
+ adding event notifications to the "Current" loop would have no
+ effect at all, events would never fire.
*/
wxASSERT_MSG( wxIsMainThread(),
wxT("Call wxSocketBase::Initialize() from the main thread first!"));
return true;
// Note that GSOCK_INPUT_LOST has to be explicitly passed to
- // _Wait becuase of the semantics of WaitForRead: a return
+ // _Wait because of the semantics of WaitForRead: a return
// value of true means that a GSocket_Read call will return
// immediately, not that there is actually data to read.
// Ctor
// --------------------------------------------------------------------------
-wxSocketServer::wxSocketServer(wxSockAddress& addr_man,
+wxSocketServer::wxSocketServer(const wxSockAddress& addr_man,
wxSocketFlags flags)
: wxSocketBase(flags, wxSOCKET_SERVER)
{
bool wxSocketBase::GetOption(int level, int optname, void *optval, int *optlen)
{
+ wxASSERT_MSG( m_socket, _T("Socket not initialised") );
+
if (m_socket->GetSockOpt(level, optname, optval, optlen)
!= GSOCK_NOERROR)
{
bool wxSocketBase::SetOption(int level, int optname, const void *optval,
int optlen)
{
+ wxASSERT_MSG( m_socket, _T("Socket not initialised") );
+
if (m_socket->SetSockOpt(level, optname, optval, optlen)
!= GSOCK_NOERROR)
{
/* NOTE: experimental stuff - might change */
-wxDatagramSocket::wxDatagramSocket( wxSockAddress& addr,
+wxDatagramSocket::wxDatagramSocket( const wxSockAddress& addr,
wxSocketFlags flags )
: wxSocketBase( flags, wxSOCKET_DATAGRAM )
{
return (*this);
}
-wxDatagramSocket& wxDatagramSocket::SendTo( wxSockAddress& addr,
+wxDatagramSocket& wxDatagramSocket::SendTo( const wxSockAddress& addr,
const void* buf,
wxUint32 nBytes )
{
+ wxASSERT_MSG( m_socket, _T("Socket not initialised") );
+
m_socket->SetPeer(addr.GetAddress());
Write(buf, nBytes);
return (*this);