// Purpose: Interprocess communication implementation (wxSocket version)
// Author: Julian Smart
// Modified by: Guilhem Lavaux (big rewrite) May 1997, 1998
// Purpose: Interprocess communication implementation (wxSocket version)
// Author: Julian Smart
// Modified by: Guilhem Lavaux (big rewrite) May 1997, 1998
// Copyright: (c) Julian Smart 1993
// (c) Guilhem Lavaux 1997, 1998
// (c) 2000 Guillermo Rodriguez <guille@iies.es>
// Copyright: (c) Julian Smart 1993
// (c) Guilhem Lavaux 1997, 1998
// (c) 2000 Guillermo Rodriguez <guille@iies.es>
/////////////////////////////////////////////////////////////////////////////
// ==========================================================================
/////////////////////////////////////////////////////////////////////////////
// ==========================================================================
// under Unix, if the server name looks like a path, create a AF_UNIX
// socket instead of AF_INET one
if ( serverName.Find(_T('/')) != wxNOT_FOUND )
// under Unix, if the server name looks like a path, create a AF_UNIX
// socket instead of AF_INET one
if ( serverName.Find(_T('/')) != wxNOT_FOUND )
wxSocketClient *client = new wxSocketClient(SCKIPC_FLAGS);
wxSocketStream *stream = new wxSocketStream(*client);
wxDataInputStream *data_is = new wxDataInputStream(*stream);
wxDataOutputStream *data_os = new wxDataOutputStream(*stream);
wxSocketClient *client = new wxSocketClient(SCKIPC_FLAGS);
wxSocketStream *stream = new wxSocketStream(*client);
wxDataInputStream *data_is = new wxDataInputStream(*stream);
wxDataOutputStream *data_os = new wxDataOutputStream(*stream);
client->SetEventHandler(*gs_handler, _CLIENT_ONREQUEST_ID);
client->SetClientData(connection);
client->SetNotify(wxSOCKET_INPUT_FLAG | wxSOCKET_LOST_FLAG);
client->SetEventHandler(*gs_handler, _CLIENT_ONREQUEST_ID);
client->SetClientData(connection);
client->SetNotify(wxSOCKET_INPUT_FLAG | wxSOCKET_LOST_FLAG);
}
m_server->SetEventHandler(*gs_handler, _SERVER_ONREQUEST_ID);
m_server->SetClientData(this);
m_server->SetNotify(wxSOCKET_CONNECTION_FLAG);
}
m_server->SetEventHandler(*gs_handler, _SERVER_ONREQUEST_ID);
m_server->SetClientData(this);
m_server->SetNotify(wxSOCKET_CONNECTION_FLAG);
}
bool wxTCPConnection::Execute(const wxChar *data, int size, wxIPCFormat format)
{
if (!m_sock->IsConnected())
}
bool wxTCPConnection::Execute(const wxChar *data, int size, wxIPCFormat format)
{
if (!m_sock->IsConnected())
// Prepare EXECUTE message
m_codeco->Write8(IPC_EXECUTE);
m_codeco->Write8(format);
if (size < 0)
// Prepare EXECUTE message
m_codeco->Write8(IPC_EXECUTE);
m_codeco->Write8(format);
if (size < 0)
wxChar *data = GetBufferAtLeast( s );
wxASSERT_MSG(data != NULL,
_T("Buffer too small in wxTCPConnection::Request") );
wxChar *data = GetBufferAtLeast( s );
wxASSERT_MSG(data != NULL,
_T("Buffer too small in wxTCPConnection::Request") );
-bool wxTCPConnection::Poke (const wxString& item, wxChar *data, int size, wxIPCFormat format)
+bool wxTCPConnection::Poke (const wxString& item, const wxChar *data, int size, wxIPCFormat format)
m_codeco->Write8(IPC_POKE);
m_codeco->WriteString(item);
m_codeco->Write8(format);
if (size < 0)
m_codeco->Write8(IPC_POKE);
m_codeco->WriteString(item);
m_codeco->Write8(format);
if (size < 0)
}
// Calls that SERVER can make
bool wxTCPConnection::Advise (const wxString& item,
}
// Calls that SERVER can make
bool wxTCPConnection::Advise (const wxString& item,
m_codeco->Write8(IPC_ADVISE);
m_codeco->WriteString(item);
m_codeco->Write8(format);
if (size < 0)
m_codeco->Write8(IPC_ADVISE);
m_codeco->WriteString(item);
m_codeco->Write8(format);
if (size < 0)
void wxTCPEventHandler::Client_OnRequest(wxSocketEvent &event)
{
wxSocketBase *sock = event.GetSocket();
void wxTCPEventHandler::Client_OnRequest(wxSocketEvent &event)
{
wxSocketBase *sock = event.GetSocket();
wxSocketNotify evt = event.GetSocketEvent();
wxTCPConnection *connection = (wxTCPConnection *)(sock->GetClientData());
wxSocketNotify evt = event.GetSocketEvent();
wxTCPConnection *connection = (wxTCPConnection *)(sock->GetClientData());
wxDataInputStream *codeci;
wxDataOutputStream *codeco;
wxSocketStream *sockstrm;
wxDataInputStream *codeci;
wxDataOutputStream *codeco;
wxSocketStream *sockstrm;
codeci = connection->m_codeci;
codeco = connection->m_codeco;
sockstrm = connection->m_sockstrm;
codeci = connection->m_codeci;
codeco = connection->m_codeco;
sockstrm = connection->m_sockstrm;
data = connection->GetBufferAtLeast( size );
wxASSERT_MSG(data != NULL,
_T("Buffer too small in wxTCPEventHandler::Client_OnRequest") );
data = connection->GetBufferAtLeast( size );
wxASSERT_MSG(data != NULL,
_T("Buffer too small in wxTCPEventHandler::Client_OnRequest") );
- char *user_data = connection->OnRequest (topic_name, item, &user_size, format);
+ const wxChar *user_data = connection->OnRequest (topic_name, item, &user_size, format);
codeco->Write32(user_size);
sockstrm->Write(user_data, user_size);
codeco->Write32(user_size);
sockstrm->Write(user_data, user_size);
void wxTCPEventHandler::Server_OnRequest(wxSocketEvent &event)
{
wxSocketServer *server = (wxSocketServer *) event.GetSocket();
void wxTCPEventHandler::Server_OnRequest(wxSocketEvent &event)
{
wxSocketServer *server = (wxSocketServer *) event.GetSocket();
wxTCPServer *ipcserv = (wxTCPServer *) server->GetClientData();
// This socket is being deleted; skip this event
wxTCPServer *ipcserv = (wxTCPServer *) server->GetClientData();
// This socket is being deleted; skip this event
// Accept the connection, getting a new socket
wxSocketBase *sock = server->Accept();
// Accept the connection, getting a new socket
wxSocketBase *sock = server->Accept();
sock->SetEventHandler(*gs_handler, _CLIENT_ONREQUEST_ID);
sock->SetClientData(new_connection);
sock->SetNotify(wxSOCKET_INPUT_FLAG | wxSOCKET_LOST_FLAG);
sock->SetEventHandler(*gs_handler, _CLIENT_ONREQUEST_ID);
sock->SetClientData(new_connection);
sock->SetNotify(wxSOCKET_INPUT_FLAG | wxSOCKET_LOST_FLAG);
// wxTCPEventHandlerModule (private class)
// --------------------------------------------------------------------------
// wxTCPEventHandlerModule (private class)
// --------------------------------------------------------------------------