// Created: 27.06.2005
// RCS-ID: $Id$
// Copyright: (c) 2005 Lukasz Michalski <lmichalski@user.sourceforge.net>
-// Licence: wxWindows license
+// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
// ============================================================================
//and list of two type worker classes that serve clients
class Server : public wxApp
{
- DECLARE_EVENT_TABLE();
+ DECLARE_EVENT_TABLE()
public:
Server() : m_maxConnections(-1) {}
~Server() {}
void DoWrite();
void DoRead();
- DECLARE_EVENT_TABLE();
+ DECLARE_EVENT_TABLE()
};
/******************* Implementation ******************/
m_listeningSocket->SetEventHandler(*this);
m_listeningSocket->SetNotify(wxSOCKET_CONNECTION_FLAG);
m_listeningSocket->Notify(true);
- if (!m_listeningSocket->Ok())
+ if (!m_listeningSocket->IsOk())
{
wxLogError("Cannot bind listening socket");
return false;
//read message header
do
{
- m_socket->Read(m_signature,2 - m_infill);
+ m_socket->Read(m_signature + m_infill, 2 - m_infill);
if (m_socket->Error())
{
if (m_socket->LastError() != wxSOCKET_WOULDBLOCK)
m_written = 0;
LogWorker(wxString::Format("Message signature: len: %d, type: %s, size: %d (bytes)",chunks,type == 0xBE ? "b" : "kB",m_size));
break;
- } else
+ }
+ else
{
LogWorker(wxString::Format("Unknown test type %x",type));
m_socket->Close();
if (m_size == m_infill)
{
m_signature[0] = m_signature[1] = 0x0;
- delete [] m_inbuf;
- m_inbuf = NULL;
+ wxDELETEA(m_inbuf);
m_infill = 0;
return;
}
break;
case wxSOCKET_OUTPUT:
- if (m_inbuf != NULL)
+ if ( m_outbuf )
DoWrite();
break;
case wxSOCKET_CONNECTION:
- LogWorker(wxString::Format("Unexpected wxSOCKET_CONNECTION in EventWorker"),wxLOG_Error);
+ LogWorker("Unexpected wxSOCKET_CONNECTION in EventWorker", wxLOG_Error);
break;
case wxSOCKET_LOST:
{
- LogWorker(wxString::Format("Connection lost"));
+ LogWorker("Connection lost");
WorkerEvent e(this);
e.m_workerFailed = m_written != m_size;
wxGetApp().AddPendingEvent(e);
{
if (m_written == m_size)
{
- delete [] m_outbuf;
- m_outbuf = NULL;
+ wxDELETEA(m_outbuf);
m_outfill = 0;
LogWorker( "All data written");
return;