]> git.saurik.com Git - wxWidgets.git/blame - include/wx/sckipc.h
Make wxRichTextRectArray usable by other parts of wxRTC
[wxWidgets.git] / include / wx / sckipc.h
CommitLineData
f4ada568 1/////////////////////////////////////////////////////////////////////////////
80fdcdb9 2// Name: wx/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 8// Created: 1993
0834112f
GRG
9// Copyright: (c) Julian Smart 1993
10// (c) Guilhem Lavaux 1997, 1998
11// (c) 2000 Guillermo Rodriguez <guille@iies.es>
65571936 12// Licence: wxWindows licence
f4ada568 13/////////////////////////////////////////////////////////////////////////////
07e829dc 14
f4ada568
GL
15#ifndef _WX_SCKIPC_H
16#define _WX_SCKIPC_H
17
f4ada568 18#include "wx/defs.h"
26dfedc4 19
cdc59bb6 20#if wxUSE_SOCKETS && wxUSE_IPC
26dfedc4 21
f4ada568
GL
22#include "wx/ipcbase.h"
23#include "wx/socket.h"
24#include "wx/sckstrm.h"
25#include "wx/datstrm.h"
26
27/*
28 * Mini-DDE implementation
29
30 Most transactions involve a topic name and an item name (choose these
31 as befits your application).
32
33 A client can:
34
35 - ask the server to execute commands (data) associated with a topic
36 - request data from server by topic and item
37 - poke data into the server
38 - ask the server to start an advice loop on topic/item
39 - ask the server to stop an advice loop
40
41 A server can:
42
43 - respond to execute, request, poke and advice start/stop
44 - send advise data to client
45
46 Note that this limits the server in the ways it can send data to the
47 client, i.e. it can't send unsolicited information.
48 *
49 */
50
b5dbe15d
VS
51class WXDLLIMPEXP_FWD_NET wxTCPServer;
52class WXDLLIMPEXP_FWD_NET wxTCPClient;
07e829dc 53
8aea37a9
VZ
54class wxIPCSocketStreams;
55
50c549b9 56class WXDLLIMPEXP_NET wxTCPConnection : public wxConnectionBase
f4ada568 57{
f4ada568 58public:
7e73fb9c
VZ
59 wxTCPConnection() { Init(); }
60 wxTCPConnection(void *buffer, size_t size)
61 : wxConnectionBase(buffer, size)
62 {
63 Init();
64 }
f4ada568 65
7e73fb9c 66 virtual ~wxTCPConnection();
f4ada568 67
7e73fb9c
VZ
68 // implement base class pure virtual methods
69 virtual const void *Request(const wxString& item,
70 size_t *size = NULL,
71 wxIPCFormat format = wxIPC_TEXT);
72 virtual bool StartAdvise(const wxString& item);
73 virtual bool StopAdvise(const wxString& item);
74 virtual bool Disconnect(void);
75
76 // Will be used in the future to enable the compression but does nothing
77 // for now.
78 void Compress(bool on);
f4ada568 79
f4ada568 80
50c549b9 81protected:
7e73fb9c
VZ
82 virtual bool DoExecute(const void *data, size_t size, wxIPCFormat format);
83 virtual bool DoPoke(const wxString& item, const void *data, size_t size,
50c549b9 84 wxIPCFormat format);
7e73fb9c
VZ
85 virtual bool DoAdvise(const wxString& item, const void *data, size_t size,
86 wxIPCFormat format);
87
0834112f 88
8aea37a9
VZ
89 // notice that all the members below are only initialized once the
90 // connection is made, i.e. in MakeConnection() for the client objects and
91 // after OnAcceptConnection() in the server ones
92
93 // the underlying socket (wxSocketClient for IPC client and wxSocketServer
94 // for IPC server)
95 wxSocketBase *m_sock;
96
97 // various streams that we use
98 wxIPCSocketStreams *m_streams;
99
100 // the topic of this connection
101 wxString m_topic;
f784a2a9 102
7e73fb9c
VZ
103private:
104 // common part of both ctors
105 void Init();
07e829dc 106
7e73fb9c
VZ
107 friend class wxTCPServer;
108 friend class wxTCPClient;
109 friend class wxTCPEventHandler;
07e829dc 110
c0c133e1 111 wxDECLARE_NO_COPY_CLASS(wxTCPConnection);
7e73fb9c 112 DECLARE_DYNAMIC_CLASS(wxTCPConnection)
f4ada568
GL
113};
114
50c549b9 115class WXDLLIMPEXP_NET wxTCPServer : public wxServerBase
f4ada568 116{
f4ada568 117public:
7e73fb9c
VZ
118 wxTCPServer();
119 virtual ~wxTCPServer();
f6bcfd97 120
7e73fb9c
VZ
121 // Returns false on error (e.g. port number is already in use)
122 virtual bool Create(const wxString& serverName);
f6bcfd97 123
7e73fb9c 124 virtual wxConnectionBase *OnAcceptConnection(const wxString& topic);
50c549b9 125
f6bcfd97 126protected:
7e73fb9c 127 wxSocketServer *m_server;
0dbfd66d
VZ
128
129#ifdef __UNIX_LIKE__
7e73fb9c
VZ
130 // the name of the file associated to the Unix domain socket, may be empty
131 wxString m_filename;
0dbfd66d 132#endif // __UNIX_LIKE__
22f3361e 133
c0c133e1 134 wxDECLARE_NO_COPY_CLASS(wxTCPServer);
7e73fb9c 135 DECLARE_DYNAMIC_CLASS(wxTCPServer)
f4ada568
GL
136};
137
50c549b9 138class WXDLLIMPEXP_NET wxTCPClient : public wxClientBase
f4ada568 139{
54da4255 140public:
7e73fb9c 141 wxTCPClient();
f4ada568 142
7e73fb9c 143 virtual bool ValidHost(const wxString& host);
f6bcfd97 144
7e73fb9c
VZ
145 // Call this to make a connection. Returns NULL if cannot.
146 virtual wxConnectionBase *MakeConnection(const wxString& host,
147 const wxString& server,
148 const wxString& topic);
54da4255 149
7e73fb9c
VZ
150 // Callbacks to CLIENT - override at will
151 virtual wxConnectionBase *OnMakeConnection();
f784a2a9
VZ
152
153private:
7e73fb9c 154 DECLARE_DYNAMIC_CLASS(wxTCPClient)
f4ada568
GL
155};
156
cdc59bb6 157#endif // wxUSE_SOCKETS && wxUSE_IPC
26dfedc4 158
cdc59bb6 159#endif // _WX_SCKIPC_H