]> git.saurik.com Git - wxWidgets.git/blame - include/wx/sckipc.h
replaced OnCtlColor(7 params) with MSWControlColor(1 param)
[wxWidgets.git] / include / wx / sckipc.h
CommitLineData
f4ada568
GL
1/////////////////////////////////////////////////////////////////////////////
2// Name: sckipc.h
0834112f
GRG
3// Purpose: Interprocess communication implementation (wxSocket version)
4// Author: Julian Smart
5// Modified by: Guilhem Lavaux (big rewrite) May 1997, 1998
6// Guillermo Rodriguez (updated for wxSocket v2) Jan 2000
cdc59bb6 7// (callbacks deprecated) Mar 2000
f4ada568
GL
8// Created: 1993
9// RCS-ID: $Id$
0834112f
GRG
10// Copyright: (c) Julian Smart 1993
11// (c) Guilhem Lavaux 1997, 1998
12// (c) 2000 Guillermo Rodriguez <guille@iies.es>
65571936 13// Licence: wxWindows licence
f4ada568 14/////////////////////////////////////////////////////////////////////////////
07e829dc 15
f4ada568
GL
16#ifndef _WX_SCKIPC_H
17#define _WX_SCKIPC_H
18
12028905 19#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
07e829dc 20#pragma interface "sckipc.h"
f4ada568
GL
21#endif
22
23#include "wx/defs.h"
26dfedc4 24
cdc59bb6 25#if wxUSE_SOCKETS && wxUSE_IPC
26dfedc4 26
f4ada568
GL
27#include "wx/ipcbase.h"
28#include "wx/socket.h"
29#include "wx/sckstrm.h"
30#include "wx/datstrm.h"
31
32/*
33 * Mini-DDE implementation
34
35 Most transactions involve a topic name and an item name (choose these
36 as befits your application).
37
38 A client can:
39
40 - ask the server to execute commands (data) associated with a topic
41 - request data from server by topic and item
42 - poke data into the server
43 - ask the server to start an advice loop on topic/item
44 - ask the server to stop an advice loop
45
46 A server can:
47
48 - respond to execute, request, poke and advice start/stop
49 - send advise data to client
50
51 Note that this limits the server in the ways it can send data to the
52 client, i.e. it can't send unsolicited information.
53 *
54 */
55
7c4728f6
VS
56class WXDLLIMPEXP_NET wxTCPServer;
57class WXDLLIMPEXP_NET wxTCPClient;
07e829dc 58
7c4728f6 59class WXDLLIMPEXP_NET wxTCPConnection: public wxConnectionBase
f4ada568
GL
60{
61 DECLARE_DYNAMIC_CLASS(wxTCPConnection)
f6bcfd97 62
f4ada568 63public:
f010ad48 64 wxTCPConnection(wxChar *buffer, int size);
f4ada568
GL
65 wxTCPConnection();
66 virtual ~wxTCPConnection();
67
68 // Calls that CLIENT can make
0834112f 69 virtual bool Execute(const wxChar *data, int size = -1, wxIPCFormat format = wxIPC_TEXT);
d38e8d5f 70 virtual wxChar *Request(const wxString& item, int *size = NULL, wxIPCFormat format = wxIPC_TEXT);
0834112f
GRG
71 virtual bool Poke(const wxString& item, wxChar *data, int size = -1, wxIPCFormat format = wxIPC_TEXT);
72 virtual bool StartAdvise(const wxString& item);
73 virtual bool StopAdvise(const wxString& item);
f4ada568
GL
74
75 // Calls that SERVER can make
0834112f 76 virtual bool Advise(const wxString& item, wxChar *data, int size = -1, wxIPCFormat format = wxIPC_TEXT);
f4ada568
GL
77
78 // Calls that both can make
0834112f 79 virtual bool Disconnect(void);
f4ada568 80
f6bcfd97 81 // Callbacks to BOTH - override at will
d775fa82
WS
82 // Default behaviour is to delete connection and return true
83 virtual bool OnDisconnect(void) { delete this; return true; }
f4ada568 84
f6bcfd97 85 // To enable the compressor (NOTE: not implemented!)
f4ada568 86 void Compress(bool on);
0834112f 87
07e829dc 88protected:
f6bcfd97
BP
89 wxSocketBase *m_sock;
90 wxSocketStream *m_sockstrm;
91 wxDataInputStream *m_codeci;
07e829dc 92 wxDataOutputStream *m_codeco;
f6bcfd97 93 wxString m_topic;
07e829dc
GRG
94
95 friend class wxTCPServer;
96 friend class wxTCPClient;
cdc59bb6 97 friend class wxTCPEventHandler;
07e829dc 98
54da4255 99private:
4ca0f293
DW
100 //
101 // We're hiding an Execute method in ConnectionBase
cdc59bb6 102 //
4ca0f293 103 virtual bool Execute(const wxString& str)
cdc59bb6 104 { return Execute(str, -1, wxIPC_TEXT); }
22f3361e
VZ
105
106 DECLARE_NO_COPY_CLASS(wxTCPConnection)
f4ada568
GL
107};
108
109class wxTCPServer: public wxServerBase
110{
111 DECLARE_DYNAMIC_CLASS(wxTCPServer)
112
113public:
114 wxTCPConnection *topLevelConnection;
115
116 wxTCPServer();
117 virtual ~wxTCPServer();
54da4255 118
d775fa82 119 // Returns false on error (e.g. port number is already in use)
f6bcfd97
BP
120 virtual bool Create(const wxString& serverName);
121
122 // Callbacks to SERVER - override at will
f4ada568 123 virtual wxConnectionBase *OnAcceptConnection(const wxString& topic);
f6bcfd97
BP
124
125protected:
126 wxSocketServer *m_server;
0dbfd66d
VZ
127
128#ifdef __UNIX_LIKE__
129 // the name of the file associated to the Unix domain socket, may be empty
130 wxString m_filename;
131#endif // __UNIX_LIKE__
22f3361e
VZ
132
133 DECLARE_NO_COPY_CLASS(wxTCPServer)
f4ada568
GL
134};
135
136class wxTCPClient: public wxClientBase
137{
138 DECLARE_DYNAMIC_CLASS(wxTCPClient)
139
54da4255 140public:
f4ada568
GL
141 wxTCPClient();
142 virtual ~wxTCPClient();
143
144 virtual bool ValidHost(const wxString& host);
f6bcfd97
BP
145
146 // Call this to make a connection. Returns NULL if cannot.
f4ada568
GL
147 virtual wxConnectionBase *MakeConnection(const wxString& host,
148 const wxString& server,
149 const wxString& topic);
54da4255 150
f6bcfd97 151 // Callbacks to CLIENT - override at will
f4ada568
GL
152 virtual wxConnectionBase *OnMakeConnection();
153};
154
cdc59bb6 155#endif // wxUSE_SOCKETS && wxUSE_IPC
26dfedc4 156
cdc59bb6 157#endif // _WX_SCKIPC_H