]> git.saurik.com Git - wxWidgets.git/blame - include/wx/sckipc.h
Override SetLogicalOrigin and SetDeviceOrigin in GNOME
[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
f4ada568 19#include "wx/defs.h"
26dfedc4 20
cdc59bb6 21#if wxUSE_SOCKETS && wxUSE_IPC
26dfedc4 22
f4ada568
GL
23#include "wx/ipcbase.h"
24#include "wx/socket.h"
25#include "wx/sckstrm.h"
26#include "wx/datstrm.h"
27
28/*
29 * Mini-DDE implementation
30
31 Most transactions involve a topic name and an item name (choose these
32 as befits your application).
33
34 A client can:
35
36 - ask the server to execute commands (data) associated with a topic
37 - request data from server by topic and item
38 - poke data into the server
39 - ask the server to start an advice loop on topic/item
40 - ask the server to stop an advice loop
41
42 A server can:
43
44 - respond to execute, request, poke and advice start/stop
45 - send advise data to client
46
47 Note that this limits the server in the ways it can send data to the
48 client, i.e. it can't send unsolicited information.
49 *
50 */
51
7c4728f6
VS
52class WXDLLIMPEXP_NET wxTCPServer;
53class WXDLLIMPEXP_NET wxTCPClient;
07e829dc 54
7c4728f6 55class WXDLLIMPEXP_NET wxTCPConnection: public wxConnectionBase
f4ada568
GL
56{
57 DECLARE_DYNAMIC_CLASS(wxTCPConnection)
f6bcfd97 58
f4ada568 59public:
f010ad48 60 wxTCPConnection(wxChar *buffer, int size);
f4ada568
GL
61 wxTCPConnection();
62 virtual ~wxTCPConnection();
63
64 // Calls that CLIENT can make
0834112f 65 virtual bool Execute(const wxChar *data, int size = -1, wxIPCFormat format = wxIPC_TEXT);
d38e8d5f 66 virtual wxChar *Request(const wxString& item, int *size = NULL, wxIPCFormat format = wxIPC_TEXT);
0834112f
GRG
67 virtual bool Poke(const wxString& item, wxChar *data, int size = -1, wxIPCFormat format = wxIPC_TEXT);
68 virtual bool StartAdvise(const wxString& item);
69 virtual bool StopAdvise(const wxString& item);
f4ada568
GL
70
71 // Calls that SERVER can make
0834112f 72 virtual bool Advise(const wxString& item, wxChar *data, int size = -1, wxIPCFormat format = wxIPC_TEXT);
f4ada568
GL
73
74 // Calls that both can make
0834112f 75 virtual bool Disconnect(void);
f4ada568 76
f6bcfd97 77 // Callbacks to BOTH - override at will
d775fa82
WS
78 // Default behaviour is to delete connection and return true
79 virtual bool OnDisconnect(void) { delete this; return true; }
f4ada568 80
f6bcfd97 81 // To enable the compressor (NOTE: not implemented!)
f4ada568 82 void Compress(bool on);
0834112f 83
f784a2a9
VZ
84 // unhide the Execute overload from wxConnectionBase
85 virtual bool Execute(const wxString& str)
86 { return Execute(str, -1, wxIPC_TEXT); }
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
f784a2a9 99 DECLARE_NO_COPY_CLASS(wxTCPConnection)
f4ada568
GL
100};
101
968eb2ef 102class WXDLLIMPEXP_NET wxTCPServer: public wxServerBase
f4ada568 103{
f4ada568
GL
104public:
105 wxTCPConnection *topLevelConnection;
106
107 wxTCPServer();
108 virtual ~wxTCPServer();
54da4255 109
d775fa82 110 // Returns false on error (e.g. port number is already in use)
f6bcfd97
BP
111 virtual bool Create(const wxString& serverName);
112
113 // Callbacks to SERVER - override at will
f4ada568 114 virtual wxConnectionBase *OnAcceptConnection(const wxString& topic);
f6bcfd97
BP
115
116protected:
117 wxSocketServer *m_server;
0dbfd66d
VZ
118
119#ifdef __UNIX_LIKE__
120 // the name of the file associated to the Unix domain socket, may be empty
121 wxString m_filename;
122#endif // __UNIX_LIKE__
22f3361e 123
f784a2a9
VZ
124 DECLARE_NO_COPY_CLASS(wxTCPServer)
125 DECLARE_DYNAMIC_CLASS(wxTCPServer)
f4ada568
GL
126};
127
968eb2ef 128class WXDLLIMPEXP_NET wxTCPClient: public wxClientBase
f4ada568 129{
54da4255 130public:
f4ada568
GL
131 wxTCPClient();
132 virtual ~wxTCPClient();
133
134 virtual bool ValidHost(const wxString& host);
f6bcfd97
BP
135
136 // Call this to make a connection. Returns NULL if cannot.
f4ada568
GL
137 virtual wxConnectionBase *MakeConnection(const wxString& host,
138 const wxString& server,
139 const wxString& topic);
54da4255 140
f6bcfd97 141 // Callbacks to CLIENT - override at will
f4ada568 142 virtual wxConnectionBase *OnMakeConnection();
f784a2a9
VZ
143
144private:
145 DECLARE_DYNAMIC_CLASS(wxTCPClient)
f4ada568
GL
146};
147
cdc59bb6 148#endif // wxUSE_SOCKETS && wxUSE_IPC
26dfedc4 149
cdc59bb6 150#endif // _WX_SCKIPC_H