no changes at all, just reformatted to use consistent indentation before the upcoming real changes

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@56259 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2008-10-12 23:04:33 +00:00
parent 7b9b06e323
commit c2116a3579

View File

@@ -204,8 +204,8 @@ void wxSocketBase::Init()
if ( !IsInitialized() ) if ( !IsInitialized() )
{ {
// this Initialize() will be undone by wxSocketModule::OnExit(), all the // this Initialize() will be undone by wxSocketModule::OnExit(), all
// other calls to it should be matched by a call to Shutdown() // the other calls to it should be matched by a call to Shutdown()
Initialize(); Initialize();
} }
} }
@@ -225,8 +225,8 @@ wxSocketBase::wxSocketBase(wxSocketFlags flags, wxSocketType type)
wxSocketBase::~wxSocketBase() wxSocketBase::~wxSocketBase()
{ {
// Just in case the app called Destroy() *and* then deleted // Just in case the app called Destroy() *and* then deleted the socket
// the socket immediately: don't leave dangling pointers. // immediately: don't leave dangling pointers.
wxAppTraits *traits = wxTheApp ? wxTheApp->GetTraits() : NULL; wxAppTraits *traits = wxTheApp ? wxTheApp->GetTraits() : NULL;
if ( traits ) if ( traits )
traits->RemoveFromPendingDelete(this); traits->RemoveFromPendingDelete(this);
@@ -246,9 +246,9 @@ wxSocketBase::~wxSocketBase()
bool wxSocketBase::Destroy() bool wxSocketBase::Destroy()
{ {
// Delayed destruction: the socket will be deleted during the next // Delayed destruction: the socket will be deleted during the next idle
// idle loop iteration. This ensures that all pending events have // loop iteration. This ensures that all pending events have been
// been processed. // processed.
m_beingDeleted = true; m_beingDeleted = true;
// Shutdown and close the socket // Shutdown and close the socket
@@ -290,8 +290,12 @@ bool wxSocketBase::Close()
if (m_socket) if (m_socket)
{ {
// Disable callbacks // Disable callbacks
m_socket->UnsetCallback(GSOCK_INPUT_FLAG | GSOCK_OUTPUT_FLAG | m_socket->UnsetCallback(
GSOCK_LOST_FLAG | GSOCK_CONNECTION_FLAG); GSOCK_INPUT_FLAG |
GSOCK_OUTPUT_FLAG |
GSOCK_LOST_FLAG |
GSOCK_CONNECTION_FLAG
);
// Shutdown the connection // Shutdown the connection
m_socket->Shutdown(); m_socket->Shutdown();
@@ -368,10 +372,10 @@ wxUint32 wxSocketBase::_Read(void* buffer_, wxUint32 nbytes)
ret = m_socket->Read(buffer, nbytes); ret = m_socket->Read(buffer, nbytes);
if ( ret == 0 ) if ( ret == 0 )
{ {
// for connection-oriented (e.g. TCP) sockets we can only read 0 // for connection-oriented (e.g. TCP) sockets we can only read
// bytes if the other end has been closed, and for connectionless // 0 bytes if the other end has been closed, and for
// ones (UDP) this flag doesn't make sense anyhow so we can set it to // connectionless ones (UDP) this flag doesn't make sense
// true too without doing any harm // anyhow so we can set it to true too without doing any harm
m_closed = true; m_closed = true;
break; break;
} }
@@ -448,7 +452,7 @@ wxSocketBase& wxSocketBase::ReadMsg(void* buffer, wxUint32 nbytes)
else else
len2 = 0; len2 = 0;
// Don't attemp to read if the msg was zero bytes long. // Don't attempt to read if the msg was zero bytes long.
if (len) if (len)
{ {
total = _Read(buffer, len); total = _Read(buffer, len);
@@ -456,6 +460,7 @@ wxSocketBase& wxSocketBase::ReadMsg(void* buffer, wxUint32 nbytes)
if (total != len) if (total != len)
goto exit; goto exit;
} }
if (len2) if (len2)
{ {
char *discard_buffer = new char[MAX_DISCARD_SIZE]; char *discard_buffer = new char[MAX_DISCARD_SIZE];
@@ -641,7 +646,10 @@ wxSocketBase& wxSocketBase::WriteMsg(const void *buffer, wxUint32 nbytes)
msg.sig[1] = (unsigned char) 0xfe; msg.sig[1] = (unsigned char) 0xfe;
msg.sig[2] = (unsigned char) 0xad; msg.sig[2] = (unsigned char) 0xad;
msg.sig[3] = (unsigned char) 0xde; msg.sig[3] = (unsigned char) 0xde;
msg.len[0] = msg.len[1] = msg.len[2] = msg.len[3] = (char) 0; msg.len[0] =
msg.len[1] =
msg.len[2] =
msg.len[3] = (char) 0;
if ((_Write(&msg, sizeof(msg))) < sizeof(msg)) if ((_Write(&msg, sizeof(msg))) < sizeof(msg))
goto exit; goto exit;
@@ -795,13 +803,14 @@ bool wxSocketBase::_Wait(long seconds,
{ {
if (eventLoop) if (eventLoop)
{ {
// from the main thread itself we have to run the event loop to let the // from the main thread itself we have to run the event loop to
// events (including the GUI events and the low-level (not wxWidgets) // let the events (including the GUI events and the low-level
// events from GSocket) be processed but from another thread it is // (not wxWidgets) events from GSocket) be processed but from
// enough to just call wxThread::Yield() which will give away the rest // another thread it is enough to just call wxThread::Yield()
// of our time slice: the explanation is that the events will be // which will give away the rest of our time slice: the
// processed by the main thread anyhow, but we don't want to eat the // explanation is that the events will be processed by the main
// CPU time uselessly while sitting in the loop waiting for the data // thread anyhow, but we don't want to eat the CPU time
// uselessly while sitting in the loop waiting for the data
if ( wxIsMainThread() ) if ( wxIsMainThread() )
{ {
if ( eventLoop->Pending() ) if ( eventLoop->Pending() )
@@ -847,8 +856,7 @@ bool wxSocketBase::WaitForRead(long seconds, long milliseconds)
// value of true means that a GSocket_Read call will return // value of true means that a GSocket_Read call will return
// immediately, not that there is actually data to read. // immediately, not that there is actually data to read.
return _Wait(seconds, milliseconds, GSOCK_INPUT_FLAG | return _Wait(seconds, milliseconds, GSOCK_INPUT_FLAG | GSOCK_LOST_FLAG);
GSOCK_LOST_FLAG);
} }
@@ -1024,9 +1032,6 @@ void wxSocketBase::OnRequest(wxSocketNotify notification)
m_connected = false; m_connected = false;
m_establishing = false; m_establishing = false;
break; break;
default:
break;
} }
// Schedule the event // Schedule the event
@@ -1323,13 +1328,17 @@ bool wxSocketClient::DoConnect(const wxSockAddress& addr_man,
return false; return false;
m_socket->SetTimeout(m_timeout * 1000); m_socket->SetTimeout(m_timeout * 1000);
m_socket->SetCallback(GSOCK_INPUT_FLAG | GSOCK_OUTPUT_FLAG | m_socket->SetCallback(
GSOCK_LOST_FLAG | GSOCK_CONNECTION_FLAG, GSOCK_INPUT_FLAG |
wx_socket_callback, (char *)this); GSOCK_OUTPUT_FLAG |
GSOCK_LOST_FLAG |
GSOCK_CONNECTION_FLAG,
wx_socket_callback,
(char *)this
);
// If wait == false, then the call should be nonblocking. // If wait == false, then the call should be nonblocking. When we are
// When we are finished, we put the socket to blocking mode // finished, we put the socket to blocking mode again.
// again.
if (!wait) if (!wait)
m_socket->SetNonBlocking(1); m_socket->SetNonBlocking(1);
@@ -1506,5 +1515,4 @@ private:
IMPLEMENT_DYNAMIC_CLASS(wxSocketModule, wxModule) IMPLEMENT_DYNAMIC_CLASS(wxSocketModule, wxModule)
#endif #endif // wxUSE_SOCKETS
// wxUSE_SOCKETS