]> git.saurik.com Git - wxWidgets.git/blame - include/wx/sckipc.h
Fix compilation under dll builds. Wrap source files in wxUSE_WEB checks to allow...
[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
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
b5dbe15d
VS
52class WXDLLIMPEXP_FWD_NET wxTCPServer;
53class WXDLLIMPEXP_FWD_NET wxTCPClient;
07e829dc 54
8aea37a9
VZ
55class wxIPCSocketStreams;
56
50c549b9 57class WXDLLIMPEXP_NET wxTCPConnection : public wxConnectionBase
f4ada568 58{
f4ada568 59public:
7e73fb9c
VZ
60 wxTCPConnection() { Init(); }
61 wxTCPConnection(void *buffer, size_t size)
62 : wxConnectionBase(buffer, size)
63 {
64 Init();
65 }
f4ada568 66
7e73fb9c 67 virtual ~wxTCPConnection();
f4ada568 68
7e73fb9c
VZ
69 // implement base class pure virtual methods
70 virtual const void *Request(const wxString& item,
71 size_t *size = NULL,
72 wxIPCFormat format = wxIPC_TEXT);
73 virtual bool StartAdvise(const wxString& item);
74 virtual bool StopAdvise(const wxString& item);
75 virtual bool Disconnect(void);
76
77 // Will be used in the future to enable the compression but does nothing
78 // for now.
79 void Compress(bool on);
f4ada568 80
f4ada568 81
50c549b9 82protected:
7e73fb9c
VZ
83 virtual bool DoExecute(const void *data, size_t size, wxIPCFormat format);
84 virtual bool DoPoke(const wxString& item, const void *data, size_t size,
50c549b9 85 wxIPCFormat format);
7e73fb9c
VZ
86 virtual bool DoAdvise(const wxString& item, const void *data, size_t size,
87 wxIPCFormat format);
88
0834112f 89
8aea37a9
VZ
90 // notice that all the members below are only initialized once the
91 // connection is made, i.e. in MakeConnection() for the client objects and
92 // after OnAcceptConnection() in the server ones
93
94 // the underlying socket (wxSocketClient for IPC client and wxSocketServer
95 // for IPC server)
96 wxSocketBase *m_sock;
97
98 // various streams that we use
99 wxIPCSocketStreams *m_streams;
100
101 // the topic of this connection
102 wxString m_topic;
f784a2a9 103
7e73fb9c
VZ
104private:
105 // common part of both ctors
106 void Init();
07e829dc 107
7e73fb9c
VZ
108 friend class wxTCPServer;
109 friend class wxTCPClient;
110 friend class wxTCPEventHandler;
07e829dc 111
c0c133e1 112 wxDECLARE_NO_COPY_CLASS(wxTCPConnection);
7e73fb9c 113 DECLARE_DYNAMIC_CLASS(wxTCPConnection)
f4ada568
GL
114};
115
50c549b9 116class WXDLLIMPEXP_NET wxTCPServer : public wxServerBase
f4ada568 117{
f4ada568 118public:
7e73fb9c
VZ
119 wxTCPServer();
120 virtual ~wxTCPServer();
f6bcfd97 121
7e73fb9c
VZ
122 // Returns false on error (e.g. port number is already in use)
123 virtual bool Create(const wxString& serverName);
f6bcfd97 124
7e73fb9c 125 virtual wxConnectionBase *OnAcceptConnection(const wxString& topic);
50c549b9 126
f6bcfd97 127protected:
7e73fb9c 128 wxSocketServer *m_server;
0dbfd66d
VZ
129
130#ifdef __UNIX_LIKE__
7e73fb9c
VZ
131 // the name of the file associated to the Unix domain socket, may be empty
132 wxString m_filename;
0dbfd66d 133#endif // __UNIX_LIKE__
22f3361e 134
c0c133e1 135 wxDECLARE_NO_COPY_CLASS(wxTCPServer);
7e73fb9c 136 DECLARE_DYNAMIC_CLASS(wxTCPServer)
f4ada568
GL
137};
138
50c549b9 139class WXDLLIMPEXP_NET wxTCPClient : public wxClientBase
f4ada568 140{
54da4255 141public:
7e73fb9c 142 wxTCPClient();
f4ada568 143
7e73fb9c 144 virtual bool ValidHost(const wxString& host);
f6bcfd97 145
7e73fb9c
VZ
146 // Call this to make a connection. Returns NULL if cannot.
147 virtual wxConnectionBase *MakeConnection(const wxString& host,
148 const wxString& server,
149 const wxString& topic);
54da4255 150
7e73fb9c
VZ
151 // Callbacks to CLIENT - override at will
152 virtual wxConnectionBase *OnMakeConnection();
f784a2a9
VZ
153
154private:
7e73fb9c 155 DECLARE_DYNAMIC_CLASS(wxTCPClient)
f4ada568
GL
156};
157
cdc59bb6 158#endif // wxUSE_SOCKETS && wxUSE_IPC
26dfedc4 159
cdc59bb6 160#endif // _WX_SCKIPC_H