#pragma hdrstop
#endif
-#if !USE_SHARED_LIBRARY
IMPLEMENT_DYNAMIC_CLASS(wxTCPServer, wxServerBase)
IMPLEMENT_DYNAMIC_CLASS(wxTCPClient, wxClientBase)
IMPLEMENT_DYNAMIC_CLASS(wxTCPConnection, wxConnectionBase)
-#endif
// It seems to be already defined somewhere in the Xt includes.
#ifndef __XT__
#endif
void Server_OnRequest(wxSocketServer& server,
- wxSocketBase::wxRequestEvent evt,
+ wxSocketNotify evt,
char *cdata);
void Client_OnRequest(wxSocketBase& sock,
- wxSocketBase::wxRequestEvent evt,
+ wxSocketNotify evt,
char *cdata);
// ---------------------------------------------------------------------------
// wxTCPClient
// ---------------------------------------------------------------------------
-wxTCPClient::wxTCPClient (void)
+wxTCPClient::wxTCPClient ()
: wxClientBase()
{
}
-wxTCPClient::~wxTCPClient (void)
+wxTCPClient::~wxTCPClient ()
{
}
const wxString& topic)
{
wxIPV4address addr;
- wxSocketHandler *hsock = &wxSocketHandler::Master();
- wxSocketClient *client = hsock->CreateClient();
+ wxSocketClient *client = new wxSocketClient();
wxSocketStream *stream = new wxSocketStream(*client);
wxDataInputStream data_is(*stream);
wxDataOutputStream data_os(*stream);
- client->SetNotify(wxSocketBase::REQ_READ | wxSocketBase::REQ_LOST);
+ client->SetNotify(wxSOCKET_INPUT_FLAG | wxSOCKET_LOST_FLAG);
addr.Service(server_name);
addr.Hostname(host);
delete client;
return NULL;
}
- return NULL;
}
wxConnectionBase *wxTCPClient::OnMakeConnection()
// wxTCPServer
// ---------------------------------------------------------------------------
-wxTCPServer::wxTCPServer (void)
+wxTCPServer::wxTCPServer ()
: wxServerBase()
{
}
bool wxTCPServer::Create(const wxString& server_name)
{
wxIPV4address addr;
- wxSocketHandler *hsock = &wxSocketHandler::Master();
wxSocketServer *server;
addr.Service(server_name);
// Create a socket listening on specified port
- server = hsock->CreateServer(addr);
+ server = new wxSocketServer(addr);
server->Callback((wxSocketBase::wxSockCbk)Server_OnRequest);
- server->SetNotify(wxSocketBase::REQ_ACCEPT);
+ server->SetNotify(wxSOCKET_CONNECTION_FLAG);
server->CallbackData((char *)this);
return TRUE;
}
-wxTCPServer::~wxTCPServer(void)
+wxTCPServer::~wxTCPServer()
{
}
// wxTCPConnection
// ---------------------------------------------------------------------------
-wxTCPConnection::wxTCPConnection (void)
+wxTCPConnection::wxTCPConnection ()
: wxConnectionBase(),
m_sock(NULL), m_sockstrm(NULL), m_codeci(NULL), m_codeco(NULL)
{
}
-wxTCPConnection::wxTCPConnection(char *buffer, int size)
+wxTCPConnection::wxTCPConnection(char * WXUNUSED(buffer), int WXUNUSED(size))
{
}
-wxTCPConnection::~wxTCPConnection (void)
+wxTCPConnection::~wxTCPConnection ()
{
wxDELETE(m_sock);
wxDELETE(m_codeci);
}
// Calls that CLIENT can make.
-bool wxTCPConnection::Disconnect (void)
+bool wxTCPConnection::Disconnect ()
{
// Send the the disconnect message to the peer.
m_codeco->Write8(IPC_DISCONNECT);
return TRUE;
}
-bool wxTCPConnection::Execute (wxChar *data, int size, wxIPCFormat format)
+bool wxTCPConnection::Execute (const wxChar *data, int size, wxIPCFormat format)
{
if (!m_sock->IsConnected())
return FALSE;
m_codeco->WriteString(data);
else {
m_codeco->Write32(size);
- m_codeco->Write(data, size);
+ m_sockstrm->Write(data, size);
}
return TRUE;
s = m_codeci->Read32();
data = new char[s];
- m_codeci->Read(data, s);
+ m_sockstrm->Read(data, s);
if (size)
*size = s;
m_codeco->WriteString(data);
else {
m_codeco->Write32(size);
- m_codeco->Write(data, size);
+ m_sockstrm->Write(data, size);
}
return TRUE;
m_codeco->WriteString(data);
else {
m_codeco->Write32(size);
- m_codeco->Write(data, size);
+ m_sockstrm->Write(data, size);
}
return TRUE;
}
-void Client_OnRequest(wxSocketBase& sock, wxSocketBase::wxRequestEvent evt,
+void Client_OnRequest(wxSocketBase& sock, wxSocketNotify evt,
char *cdata)
{
int msg = 0;
wxTCPConnection *connection = (wxTCPConnection *)cdata;
wxDataInputStream *codeci;
wxDataOutputStream *codeco;
+ wxSocketStream *sockstrm;
wxString topic_name = connection->m_topic;
wxString item;
// The socket handler signals us that we lost the connection: destroy all.
- if (evt == wxSocketBase::EVT_LOST) {
+ if (evt == wxSOCKET_LOST) {
sock.Close();
connection->OnDisconnect();
return;
// Receive message number.
codeci = connection->m_codeci;
codeco = connection->m_codeco;
+ sockstrm = connection->m_sockstrm;
msg = codeci->Read8();
switch (msg) {
format = (wxIPCFormat)codeci->Read8();
size = codeci->Read32();
data = new char[size];
- codeci->Read(data, size);
+ sockstrm->Read(data, size);
connection->OnExecute (topic_name, data, size, format);
format = (wxIPCFormat)codeci->Read8();
size = codeci->Read32();
data = new char[size];
- codeci->Read(data, size);
+ sockstrm->Read(data, size);
connection->OnAdvise (topic_name, item, data, size, format);
format = (wxIPCFormat)codeci->Read8();
size = codeci->Read32();
data = new wxChar[size];
- codeci->Read(data, size);
+ sockstrm->Read(data, size);
connection->OnPoke (topic_name, item, data, size, format);
codeco->Write8(IPC_REQUEST_REPLY);
if (user_size != -1) {
codeco->Write32(user_size);
- codeco->Write(user_data, user_size);
+ sockstrm->Write(user_data, user_size);
} else
codeco->WriteString(user_data);
} else
}
void Server_OnRequest(wxSocketServer& server,
- wxSocketBase::wxRequestEvent evt, char *cdata)
+ wxSocketNotify evt, char *cdata)
{
wxTCPServer *ipcserv = (wxTCPServer *)cdata;
wxSocketStream *stream;
wxDataInputStream *codeci;
wxDataOutputStream *codeco;
- if (evt != wxSocketBase::EVT_ACCEPT)
+ if (evt != wxSOCKET_CONNECTION)
return;
/* Accept the connection, getting a new socket */
wxSocketBase *sock = server.Accept();
sock->Notify(FALSE);
- sock->SetNotify(wxSocketBase::REQ_READ | wxSocketBase::REQ_LOST);
+ sock->SetNotify(wxSOCKET_INPUT_FLAG | wxSOCKET_LOST_FLAG);
stream = new wxSocketStream(*sock);
codeci = new wxDataInputStream(*stream);