1998-05-20 14:01:55 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
2011-03-20 00:14:35 +00:00
|
|
|
// Name: wx/ipcbase.h
|
1998-05-20 14:01:55 +00:00
|
|
|
// Purpose: Base classes for IPC
|
|
|
|
// Author: Julian Smart
|
|
|
|
// Modified by:
|
|
|
|
// Created: 4/1/98
|
2003-03-17 10:34:04 +00:00
|
|
|
// Copyright: (c) Julian Smart
|
2004-05-23 20:53:33 +00:00
|
|
|
// Licence: wxWindows licence
|
1998-05-20 14:01:55 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
1998-08-15 00:23:28 +00:00
|
|
|
#ifndef _WX_IPCBASEH__
|
|
|
|
#define _WX_IPCBASEH__
|
1998-05-20 14:01:55 +00:00
|
|
|
|
|
|
|
#include "wx/defs.h"
|
|
|
|
#include "wx/object.h"
|
|
|
|
#include "wx/string.h"
|
|
|
|
|
1999-01-19 16:33:16 +00:00
|
|
|
enum wxIPCFormat
|
|
|
|
{
|
|
|
|
wxIPC_INVALID = 0,
|
|
|
|
wxIPC_TEXT = 1, /* CF_TEXT */
|
|
|
|
wxIPC_BITMAP = 2, /* CF_BITMAP */
|
|
|
|
wxIPC_METAFILE = 3, /* CF_METAFILEPICT */
|
|
|
|
wxIPC_SYLK = 4,
|
|
|
|
wxIPC_DIF = 5,
|
|
|
|
wxIPC_TIFF = 6,
|
|
|
|
wxIPC_OEMTEXT = 7, /* CF_OEMTEXT */
|
|
|
|
wxIPC_DIB = 8, /* CF_DIB */
|
|
|
|
wxIPC_PALETTE = 9,
|
|
|
|
wxIPC_PENDATA = 10,
|
|
|
|
wxIPC_RIFF = 11,
|
|
|
|
wxIPC_WAVE = 12,
|
2007-10-20 22:54:26 +00:00
|
|
|
wxIPC_UTF16TEXT = 13, /* CF_UNICODE */
|
1999-01-19 16:33:16 +00:00
|
|
|
wxIPC_ENHMETAFILE = 14,
|
|
|
|
wxIPC_FILENAME = 15, /* CF_HDROP */
|
|
|
|
wxIPC_LOCALE = 16,
|
2007-10-20 22:54:26 +00:00
|
|
|
wxIPC_UTF8TEXT = 17,
|
|
|
|
wxIPC_UTF32TEXT = 18,
|
|
|
|
#if SIZEOF_WCHAR_T == 2
|
|
|
|
wxIPC_UNICODETEXT = wxIPC_UTF16TEXT,
|
|
|
|
#elif SIZEOF_WCHAR_T == 4
|
|
|
|
wxIPC_UNICODETEXT = wxIPC_UTF32TEXT,
|
|
|
|
#else
|
|
|
|
# error "Unknown wchar_t size"
|
|
|
|
#endif
|
1999-01-19 16:33:16 +00:00
|
|
|
wxIPC_PRIVATE = 20
|
|
|
|
};
|
|
|
|
|
2007-07-09 10:09:52 +00:00
|
|
|
class WXDLLIMPEXP_FWD_BASE wxServerBase;
|
|
|
|
class WXDLLIMPEXP_FWD_BASE wxClientBase;
|
1998-05-20 14:01:55 +00:00
|
|
|
|
2003-07-02 01:59:24 +00:00
|
|
|
class WXDLLIMPEXP_BASE wxConnectionBase: public wxObject
|
1998-05-20 14:01:55 +00:00
|
|
|
{
|
2000-07-15 19:51:35 +00:00
|
|
|
public:
|
2007-10-20 22:54:26 +00:00
|
|
|
wxConnectionBase(void *buffer, size_t size); // use external buffer
|
Applied patch [ 600051 ] DDE and TCP improvements and fixes
By Michael Fielding
As discussed on wx-dev. some fixes and improvements for Interprocess Communication (IPC), using DDE and TCP.
1. DDE buffers were using a global buffer
2. TCP buffers were allocated each time needed, and Request would have caused memory leaks had it been used.
Fixed these both by using a self-resizing buffer in wxConnectionBase. Changed samples and docs to reflect the improved (but backward compatible) internal buffer management. wxConnectionBase could (in future) use wxMemoryBuffer.
3. IPC sample had trouble closing, causing crash, when closing server using window X button.
Because it was (effectively) trying to delete a window in OnExit, when that window was already destroyed. Fixed by making IPCDialog and MyConnection remember if they'd destroyed each other. It's not elegant, but either the connection or the window could be deleted first.
4. Docs for wxDDE... and wxTCP... duplicated eachother, supposed to have same API. Some parts unclear.
Patch removes dde and tcp-specific files (including from tipc.tex and classes.tex), and explains how ipc.h selects for you which one to use based on platform. Some other misc clarifications.
6. Client sample was suffering apparent memory leak because of not deleting connection object, and had a hack in there to do that.
In fact this was due to the derived OnDisconnect not deleting itself, as it does in base class. Mentioned need to do it in docs, fixed sample so that it does.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@16907 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2002-09-01 14:48:16 +00:00
|
|
|
wxConnectionBase(); // use internal, adaptive buffer
|
2005-09-24 21:43:15 +00:00
|
|
|
wxConnectionBase(const wxConnectionBase& copy);
|
2007-10-20 22:54:26 +00:00
|
|
|
virtual ~wxConnectionBase();
|
Applied patch [ 600051 ] DDE and TCP improvements and fixes
By Michael Fielding
As discussed on wx-dev. some fixes and improvements for Interprocess Communication (IPC), using DDE and TCP.
1. DDE buffers were using a global buffer
2. TCP buffers were allocated each time needed, and Request would have caused memory leaks had it been used.
Fixed these both by using a self-resizing buffer in wxConnectionBase. Changed samples and docs to reflect the improved (but backward compatible) internal buffer management. wxConnectionBase could (in future) use wxMemoryBuffer.
3. IPC sample had trouble closing, causing crash, when closing server using window X button.
Because it was (effectively) trying to delete a window in OnExit, when that window was already destroyed. Fixed by making IPCDialog and MyConnection remember if they'd destroyed each other. It's not elegant, but either the connection or the window could be deleted first.
4. Docs for wxDDE... and wxTCP... duplicated eachother, supposed to have same API. Some parts unclear.
Patch removes dde and tcp-specific files (including from tipc.tex and classes.tex), and explains how ipc.h selects for you which one to use based on platform. Some other misc clarifications.
6. Client sample was suffering apparent memory leak because of not deleting connection object, and had a hack in there to do that.
In fact this was due to the derived OnDisconnect not deleting itself, as it does in base class. Mentioned need to do it in docs, fixed sample so that it does.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@16907 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2002-09-01 14:48:16 +00:00
|
|
|
|
|
|
|
void SetConnected( bool c ) { m_connected = c; }
|
|
|
|
bool GetConnected() { return m_connected; }
|
1998-05-20 14:01:55 +00:00
|
|
|
|
|
|
|
// Calls that CLIENT can make
|
2007-10-20 22:54:26 +00:00
|
|
|
bool Execute(const void *data, size_t size, wxIPCFormat fmt = wxIPC_PRIVATE)
|
|
|
|
{ return DoExecute(data, size, fmt); }
|
|
|
|
bool Execute(const char *s, size_t size = wxNO_LEN)
|
|
|
|
{ return DoExecute(s, size == wxNO_LEN ? strlen(s) + 1
|
|
|
|
: size, wxIPC_TEXT); }
|
|
|
|
bool Execute(const wchar_t *ws, size_t size = wxNO_LEN)
|
|
|
|
{ return DoExecute(ws, size == wxNO_LEN ? (wcslen(ws) + 1)*sizeof(wchar_t)
|
|
|
|
: size, wxIPC_UNICODETEXT); }
|
|
|
|
bool Execute(const wxString& s)
|
|
|
|
{
|
2009-03-30 18:28:42 +00:00
|
|
|
const wxScopedCharBuffer buf = s.utf8_str();
|
2007-10-20 22:54:26 +00:00
|
|
|
return DoExecute(buf, strlen(buf) + 1, wxIPC_UTF8TEXT);
|
|
|
|
}
|
|
|
|
bool Execute(const wxCStrData& cs)
|
|
|
|
{ return Execute(cs.AsString()); }
|
|
|
|
|
|
|
|
virtual const void *Request(const wxString& item,
|
|
|
|
size_t *size = NULL,
|
|
|
|
wxIPCFormat format = wxIPC_TEXT) = 0;
|
|
|
|
|
|
|
|
bool Poke(const wxString& item, const void *data, size_t size,
|
|
|
|
wxIPCFormat fmt = wxIPC_PRIVATE)
|
|
|
|
{ return DoPoke(item, data, size, fmt); }
|
|
|
|
bool Poke(const wxString& item, const char *s, size_t size = wxNO_LEN)
|
|
|
|
{ return DoPoke(item, s, size == wxNO_LEN ? strlen(s) + 1
|
|
|
|
: size, wxIPC_TEXT); }
|
|
|
|
bool Poke(const wxString& item, const wchar_t *ws, size_t size = wxNO_LEN)
|
|
|
|
{ return DoPoke(item, ws,
|
|
|
|
size == wxNO_LEN ? (wcslen(ws) + 1)*sizeof(wchar_t)
|
|
|
|
: size, wxIPC_UNICODETEXT); }
|
2014-01-20 14:45:08 +00:00
|
|
|
bool Poke(const wxString& item, const wxString& s)
|
2007-10-20 22:54:26 +00:00
|
|
|
{
|
2009-03-30 18:28:42 +00:00
|
|
|
const wxScopedCharBuffer buf = s.utf8_str();
|
2007-10-20 22:54:26 +00:00
|
|
|
return DoPoke(item, buf, strlen(buf) + 1, wxIPC_UTF8TEXT);
|
|
|
|
}
|
|
|
|
bool Poke(const wxString& item, const wxCStrData& cs)
|
|
|
|
{ return Poke(item, cs.AsString()); }
|
|
|
|
|
1998-05-20 14:01:55 +00:00
|
|
|
virtual bool StartAdvise(const wxString& item) = 0;
|
|
|
|
virtual bool StopAdvise(const wxString& item) = 0;
|
|
|
|
|
|
|
|
// Calls that SERVER can make
|
2007-10-20 22:54:26 +00:00
|
|
|
bool Advise(const wxString& item, const void *data, size_t size,
|
|
|
|
wxIPCFormat fmt = wxIPC_PRIVATE)
|
|
|
|
{ return DoAdvise(item, data, size, fmt); }
|
|
|
|
bool Advise(const wxString& item, const char *s, size_t size = wxNO_LEN)
|
|
|
|
{ return DoAdvise(item, s, size == wxNO_LEN ? strlen(s) + 1
|
|
|
|
: size, wxIPC_TEXT); }
|
|
|
|
bool Advise(const wxString& item, const wchar_t *ws, size_t size = wxNO_LEN)
|
|
|
|
{ return DoAdvise(item, ws,
|
|
|
|
size == wxNO_LEN ? (wcslen(ws) + 1)*sizeof(wchar_t)
|
|
|
|
: size, wxIPC_UNICODETEXT); }
|
2014-01-20 14:45:08 +00:00
|
|
|
bool Advise(const wxString& item, const wxString& s)
|
2007-10-20 22:54:26 +00:00
|
|
|
{
|
2009-03-30 18:28:42 +00:00
|
|
|
const wxScopedCharBuffer buf = s.utf8_str();
|
2007-10-20 22:54:26 +00:00
|
|
|
return DoAdvise(item, buf, strlen(buf) + 1, wxIPC_UTF8TEXT);
|
|
|
|
}
|
|
|
|
bool Advise(const wxString& item, const wxCStrData& cs)
|
|
|
|
{ return Advise(item, cs.AsString()); }
|
1998-05-20 14:01:55 +00:00
|
|
|
|
|
|
|
// Calls that both can make
|
2007-10-20 22:54:26 +00:00
|
|
|
virtual bool Disconnect() = 0;
|
|
|
|
|
1998-05-20 14:01:55 +00:00
|
|
|
|
|
|
|
// Callbacks to SERVER - override at will
|
2008-01-12 21:04:10 +00:00
|
|
|
virtual bool OnExec(const wxString& WXUNUSED(topic),
|
|
|
|
const wxString& WXUNUSED(data))
|
2008-05-02 22:05:43 +00:00
|
|
|
{
|
|
|
|
wxFAIL_MSG( "This method shouldn't be called, if it is, it probably "
|
|
|
|
"means that you didn't update your old code overriding "
|
|
|
|
"OnExecute() to use the new parameter types (\"const void *\" "
|
|
|
|
"instead of \"wxChar *\" and \"size_t\" instead of \"int\"), "
|
|
|
|
"you must do it or your code wouldn't be executed at all!" );
|
|
|
|
return false;
|
|
|
|
}
|
2007-10-20 22:54:26 +00:00
|
|
|
|
2008-01-12 21:04:10 +00:00
|
|
|
// deprecated function kept for backwards compatibility: usually you will
|
|
|
|
// want to override OnExec() above instead which receives its data in a more
|
|
|
|
// convenient format
|
|
|
|
virtual bool OnExecute(const wxString& topic,
|
|
|
|
const void *data,
|
|
|
|
size_t size,
|
|
|
|
wxIPCFormat format)
|
|
|
|
{ return OnExec(topic, GetTextFromData(data, size, format)); }
|
|
|
|
|
2007-10-20 22:54:26 +00:00
|
|
|
virtual const void *OnRequest(const wxString& WXUNUSED(topic),
|
|
|
|
const wxString& WXUNUSED(item),
|
|
|
|
size_t *size,
|
|
|
|
wxIPCFormat WXUNUSED(format))
|
|
|
|
{ *size = 0; return NULL; }
|
|
|
|
|
|
|
|
virtual bool OnPoke(const wxString& WXUNUSED(topic),
|
|
|
|
const wxString& WXUNUSED(item),
|
|
|
|
const void *WXUNUSED(data),
|
|
|
|
size_t WXUNUSED(size),
|
|
|
|
wxIPCFormat WXUNUSED(format))
|
|
|
|
{ return false; }
|
|
|
|
|
|
|
|
virtual bool OnStartAdvise(const wxString& WXUNUSED(topic),
|
|
|
|
const wxString& WXUNUSED(item))
|
|
|
|
{ return false; }
|
|
|
|
|
|
|
|
virtual bool OnStopAdvise(const wxString& WXUNUSED(topic),
|
|
|
|
const wxString& WXUNUSED(item))
|
|
|
|
{ return false; }
|
1998-05-20 14:01:55 +00:00
|
|
|
|
|
|
|
// Callbacks to CLIENT - override at will
|
2007-10-20 22:54:26 +00:00
|
|
|
virtual bool OnAdvise(const wxString& WXUNUSED(topic),
|
|
|
|
const wxString& WXUNUSED(item),
|
|
|
|
const void *WXUNUSED(data),
|
|
|
|
size_t WXUNUSED(size),
|
|
|
|
wxIPCFormat WXUNUSED(format))
|
|
|
|
{ return false; }
|
|
|
|
|
|
|
|
// Callbacks to BOTH
|
|
|
|
virtual bool OnDisconnect() { delete this; return true; }
|
1998-05-20 14:01:55 +00:00
|
|
|
|
Applied patch [ 600051 ] DDE and TCP improvements and fixes
By Michael Fielding
As discussed on wx-dev. some fixes and improvements for Interprocess Communication (IPC), using DDE and TCP.
1. DDE buffers were using a global buffer
2. TCP buffers were allocated each time needed, and Request would have caused memory leaks had it been used.
Fixed these both by using a self-resizing buffer in wxConnectionBase. Changed samples and docs to reflect the improved (but backward compatible) internal buffer management. wxConnectionBase could (in future) use wxMemoryBuffer.
3. IPC sample had trouble closing, causing crash, when closing server using window X button.
Because it was (effectively) trying to delete a window in OnExit, when that window was already destroyed. Fixed by making IPCDialog and MyConnection remember if they'd destroyed each other. It's not elegant, but either the connection or the window could be deleted first.
4. Docs for wxDDE... and wxTCP... duplicated eachother, supposed to have same API. Some parts unclear.
Patch removes dde and tcp-specific files (including from tipc.tex and classes.tex), and explains how ipc.h selects for you which one to use based on platform. Some other misc clarifications.
6. Client sample was suffering apparent memory leak because of not deleting connection object, and had a hack in there to do that.
In fact this was due to the derived OnDisconnect not deleting itself, as it does in base class. Mentioned need to do it in docs, fixed sample so that it does.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@16907 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2002-09-01 14:48:16 +00:00
|
|
|
|
2008-10-16 12:32:06 +00:00
|
|
|
// return true if this is one of the formats used for textual data
|
|
|
|
// transmission
|
|
|
|
static bool IsTextFormat(wxIPCFormat format)
|
|
|
|
{
|
|
|
|
return format == wxIPC_TEXT ||
|
|
|
|
format == wxIPC_UTF8TEXT ||
|
|
|
|
format == wxIPC_UTF16TEXT ||
|
|
|
|
format == wxIPC_UTF32TEXT;
|
|
|
|
}
|
|
|
|
|
2008-01-12 21:04:10 +00:00
|
|
|
// converts from the data and format into a wxString automatically
|
|
|
|
//
|
|
|
|
// this function accepts data in all of wxIPC_TEXT, wxIPC_UNICODETEXT, and
|
2008-10-16 12:32:06 +00:00
|
|
|
// wxIPC_UTF8TEXT formats but asserts if the format is anything else (i.e.
|
|
|
|
// such that IsTextFormat(format) doesn't return true)
|
2008-01-12 21:04:10 +00:00
|
|
|
//
|
|
|
|
// notice that the size parameter here contains the total size of the data,
|
|
|
|
// including the terminating '\0' or L'\0'
|
|
|
|
static
|
|
|
|
wxString GetTextFromData(const void *data, size_t size, wxIPCFormat format);
|
|
|
|
|
|
|
|
|
Applied patch [ 600051 ] DDE and TCP improvements and fixes
By Michael Fielding
As discussed on wx-dev. some fixes and improvements for Interprocess Communication (IPC), using DDE and TCP.
1. DDE buffers were using a global buffer
2. TCP buffers were allocated each time needed, and Request would have caused memory leaks had it been used.
Fixed these both by using a self-resizing buffer in wxConnectionBase. Changed samples and docs to reflect the improved (but backward compatible) internal buffer management. wxConnectionBase could (in future) use wxMemoryBuffer.
3. IPC sample had trouble closing, causing crash, when closing server using window X button.
Because it was (effectively) trying to delete a window in OnExit, when that window was already destroyed. Fixed by making IPCDialog and MyConnection remember if they'd destroyed each other. It's not elegant, but either the connection or the window could be deleted first.
4. Docs for wxDDE... and wxTCP... duplicated eachother, supposed to have same API. Some parts unclear.
Patch removes dde and tcp-specific files (including from tipc.tex and classes.tex), and explains how ipc.h selects for you which one to use based on platform. Some other misc clarifications.
6. Client sample was suffering apparent memory leak because of not deleting connection object, and had a hack in there to do that.
In fact this was due to the derived OnDisconnect not deleting itself, as it does in base class. Mentioned need to do it in docs, fixed sample so that it does.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@16907 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2002-09-01 14:48:16 +00:00
|
|
|
// return a buffer at least this size, reallocating buffer if needed
|
2007-10-20 22:54:26 +00:00
|
|
|
// returns NULL if using an inadequate user buffer which can't be resized
|
|
|
|
void *GetBufferAtLeast(size_t bytes);
|
Applied patch [ 600051 ] DDE and TCP improvements and fixes
By Michael Fielding
As discussed on wx-dev. some fixes and improvements for Interprocess Communication (IPC), using DDE and TCP.
1. DDE buffers were using a global buffer
2. TCP buffers were allocated each time needed, and Request would have caused memory leaks had it been used.
Fixed these both by using a self-resizing buffer in wxConnectionBase. Changed samples and docs to reflect the improved (but backward compatible) internal buffer management. wxConnectionBase could (in future) use wxMemoryBuffer.
3. IPC sample had trouble closing, causing crash, when closing server using window X button.
Because it was (effectively) trying to delete a window in OnExit, when that window was already destroyed. Fixed by making IPCDialog and MyConnection remember if they'd destroyed each other. It's not elegant, but either the connection or the window could be deleted first.
4. Docs for wxDDE... and wxTCP... duplicated eachother, supposed to have same API. Some parts unclear.
Patch removes dde and tcp-specific files (including from tipc.tex and classes.tex), and explains how ipc.h selects for you which one to use based on platform. Some other misc clarifications.
6. Client sample was suffering apparent memory leak because of not deleting connection object, and had a hack in there to do that.
In fact this was due to the derived OnDisconnect not deleting itself, as it does in base class. Mentioned need to do it in docs, fixed sample so that it does.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@16907 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2002-09-01 14:48:16 +00:00
|
|
|
|
|
|
|
protected:
|
2007-10-20 22:54:26 +00:00
|
|
|
virtual bool DoExecute(const void *data, size_t size, wxIPCFormat format) = 0;
|
|
|
|
virtual bool DoPoke(const wxString& item, const void *data, size_t size,
|
|
|
|
wxIPCFormat format) = 0;
|
|
|
|
virtual bool DoAdvise(const wxString& item, const void *data, size_t size,
|
|
|
|
wxIPCFormat format) = 0;
|
|
|
|
|
|
|
|
|
Applied patch [ 600051 ] DDE and TCP improvements and fixes
By Michael Fielding
As discussed on wx-dev. some fixes and improvements for Interprocess Communication (IPC), using DDE and TCP.
1. DDE buffers were using a global buffer
2. TCP buffers were allocated each time needed, and Request would have caused memory leaks had it been used.
Fixed these both by using a self-resizing buffer in wxConnectionBase. Changed samples and docs to reflect the improved (but backward compatible) internal buffer management. wxConnectionBase could (in future) use wxMemoryBuffer.
3. IPC sample had trouble closing, causing crash, when closing server using window X button.
Because it was (effectively) trying to delete a window in OnExit, when that window was already destroyed. Fixed by making IPCDialog and MyConnection remember if they'd destroyed each other. It's not elegant, but either the connection or the window could be deleted first.
4. Docs for wxDDE... and wxTCP... duplicated eachother, supposed to have same API. Some parts unclear.
Patch removes dde and tcp-specific files (including from tipc.tex and classes.tex), and explains how ipc.h selects for you which one to use based on platform. Some other misc clarifications.
6. Client sample was suffering apparent memory leak because of not deleting connection object, and had a hack in there to do that.
In fact this was due to the derived OnDisconnect not deleting itself, as it does in base class. Mentioned need to do it in docs, fixed sample so that it does.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@16907 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2002-09-01 14:48:16 +00:00
|
|
|
private:
|
2007-10-20 22:54:26 +00:00
|
|
|
char *m_buffer;
|
Applied patch [ 600051 ] DDE and TCP improvements and fixes
By Michael Fielding
As discussed on wx-dev. some fixes and improvements for Interprocess Communication (IPC), using DDE and TCP.
1. DDE buffers were using a global buffer
2. TCP buffers were allocated each time needed, and Request would have caused memory leaks had it been used.
Fixed these both by using a self-resizing buffer in wxConnectionBase. Changed samples and docs to reflect the improved (but backward compatible) internal buffer management. wxConnectionBase could (in future) use wxMemoryBuffer.
3. IPC sample had trouble closing, causing crash, when closing server using window X button.
Because it was (effectively) trying to delete a window in OnExit, when that window was already destroyed. Fixed by making IPCDialog and MyConnection remember if they'd destroyed each other. It's not elegant, but either the connection or the window could be deleted first.
4. Docs for wxDDE... and wxTCP... duplicated eachother, supposed to have same API. Some parts unclear.
Patch removes dde and tcp-specific files (including from tipc.tex and classes.tex), and explains how ipc.h selects for you which one to use based on platform. Some other misc clarifications.
6. Client sample was suffering apparent memory leak because of not deleting connection object, and had a hack in there to do that.
In fact this was due to the derived OnDisconnect not deleting itself, as it does in base class. Mentioned need to do it in docs, fixed sample so that it does.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@16907 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2002-09-01 14:48:16 +00:00
|
|
|
size_t m_buffersize;
|
|
|
|
bool m_deletebufferwhendone;
|
2003-01-02 23:38:11 +00:00
|
|
|
|
2007-10-20 22:54:26 +00:00
|
|
|
protected:
|
2008-01-12 21:04:10 +00:00
|
|
|
bool m_connected;
|
2007-10-20 22:54:26 +00:00
|
|
|
|
2009-02-08 11:45:59 +00:00
|
|
|
wxDECLARE_NO_ASSIGN_CLASS(wxConnectionBase);
|
2015-04-23 11:49:01 +00:00
|
|
|
wxDECLARE_CLASS(wxConnectionBase);
|
1998-05-20 14:01:55 +00:00
|
|
|
};
|
|
|
|
|
Applied patch [ 600051 ] DDE and TCP improvements and fixes
By Michael Fielding
As discussed on wx-dev. some fixes and improvements for Interprocess Communication (IPC), using DDE and TCP.
1. DDE buffers were using a global buffer
2. TCP buffers were allocated each time needed, and Request would have caused memory leaks had it been used.
Fixed these both by using a self-resizing buffer in wxConnectionBase. Changed samples and docs to reflect the improved (but backward compatible) internal buffer management. wxConnectionBase could (in future) use wxMemoryBuffer.
3. IPC sample had trouble closing, causing crash, when closing server using window X button.
Because it was (effectively) trying to delete a window in OnExit, when that window was already destroyed. Fixed by making IPCDialog and MyConnection remember if they'd destroyed each other. It's not elegant, but either the connection or the window could be deleted first.
4. Docs for wxDDE... and wxTCP... duplicated eachother, supposed to have same API. Some parts unclear.
Patch removes dde and tcp-specific files (including from tipc.tex and classes.tex), and explains how ipc.h selects for you which one to use based on platform. Some other misc clarifications.
6. Client sample was suffering apparent memory leak because of not deleting connection object, and had a hack in there to do that.
In fact this was due to the derived OnDisconnect not deleting itself, as it does in base class. Mentioned need to do it in docs, fixed sample so that it does.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@16907 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2002-09-01 14:48:16 +00:00
|
|
|
|
2007-10-20 22:54:26 +00:00
|
|
|
class WXDLLIMPEXP_BASE wxServerBase : public wxObject
|
1998-05-20 14:01:55 +00:00
|
|
|
{
|
2000-07-15 19:51:35 +00:00
|
|
|
public:
|
2007-10-20 22:54:26 +00:00
|
|
|
wxServerBase() { }
|
|
|
|
virtual ~wxServerBase() { }
|
1998-05-20 14:01:55 +00:00
|
|
|
|
2004-09-16 18:13:32 +00:00
|
|
|
// Returns false on error (e.g. port number is already in use)
|
2000-07-15 19:51:35 +00:00
|
|
|
virtual bool Create(const wxString& serverName) = 0;
|
|
|
|
|
|
|
|
// Callbacks to SERVER - override at will
|
|
|
|
virtual wxConnectionBase *OnAcceptConnection(const wxString& topic) = 0;
|
2007-10-20 22:54:26 +00:00
|
|
|
|
2015-04-23 11:49:01 +00:00
|
|
|
wxDECLARE_CLASS(wxServerBase);
|
1998-05-20 14:01:55 +00:00
|
|
|
};
|
|
|
|
|
2007-10-20 22:54:26 +00:00
|
|
|
class WXDLLIMPEXP_BASE wxClientBase : public wxObject
|
1998-05-20 14:01:55 +00:00
|
|
|
{
|
2000-07-15 19:51:35 +00:00
|
|
|
public:
|
2007-10-20 22:54:26 +00:00
|
|
|
wxClientBase() { }
|
|
|
|
virtual ~wxClientBase() { }
|
2000-07-15 19:51:35 +00:00
|
|
|
|
1998-05-20 14:01:55 +00:00
|
|
|
virtual bool ValidHost(const wxString& host) = 0;
|
|
|
|
|
2000-07-15 19:51:35 +00:00
|
|
|
// Call this to make a connection. Returns NULL if cannot.
|
|
|
|
virtual wxConnectionBase *MakeConnection(const wxString& host,
|
|
|
|
const wxString& server,
|
|
|
|
const wxString& topic) = 0;
|
|
|
|
|
|
|
|
// Callbacks to CLIENT - override at will
|
2007-10-20 22:54:26 +00:00
|
|
|
virtual wxConnectionBase *OnMakeConnection() = 0;
|
|
|
|
|
2015-04-23 11:49:01 +00:00
|
|
|
wxDECLARE_CLASS(wxClientBase);
|
1998-05-20 14:01:55 +00:00
|
|
|
};
|
|
|
|
|
2007-10-20 22:54:26 +00:00
|
|
|
#endif // _WX_IPCBASEH__
|