]> git.saurik.com Git - wxWidgets.git/blame - include/wx/sckipc.h
Changed order of #ifdefs to get native version on OS/2, even if
[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
f4ada568
GL
7// Created: 1993
8// RCS-ID: $Id$
0834112f
GRG
9// Copyright: (c) Julian Smart 1993
10// (c) Guilhem Lavaux 1997, 1998
11// (c) 2000 Guillermo Rodriguez <guille@iies.es>
f4ada568
GL
12// Licence: wxWindows license
13/////////////////////////////////////////////////////////////////////////////
07e829dc 14
f4ada568
GL
15#ifndef _WX_SCKIPC_H
16#define _WX_SCKIPC_H
17
18#ifdef __GNUG__
07e829dc 19#pragma interface "sckipc.h"
f4ada568
GL
20#endif
21
22#include "wx/defs.h"
23#include "wx/setup.h"
24#include "wx/ipcbase.h"
25#include "wx/socket.h"
26#include "wx/sckstrm.h"
27#include "wx/datstrm.h"
28
29/*
30 * Mini-DDE implementation
31
32 Most transactions involve a topic name and an item name (choose these
33 as befits your application).
34
35 A client can:
36
37 - ask the server to execute commands (data) associated with a topic
38 - request data from server by topic and item
39 - poke data into the server
40 - ask the server to start an advice loop on topic/item
41 - ask the server to stop an advice loop
42
43 A server can:
44
45 - respond to execute, request, poke and advice start/stop
46 - send advise data to client
47
48 Note that this limits the server in the ways it can send data to the
49 client, i.e. it can't send unsolicited information.
50 *
51 */
52
07e829dc
GRG
53class WXDLLEXPORT wxTCPServer;
54class WXDLLEXPORT wxTCPClient;
55
56class WXDLLEXPORT wxTCPConnection: public wxConnectionBase
f4ada568
GL
57{
58 DECLARE_DYNAMIC_CLASS(wxTCPConnection)
f4ada568 59public:
f4ada568
GL
60 wxTCPConnection(char *buffer, int size);
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);
0834112f
GRG
66 virtual char *Request(const wxString& item, int *size = NULL, wxIPCFormat format = wxIPC_TEXT);
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
0834112f
GRG
77 // Default behaviour is to delete connection and return TRUE
78 virtual bool OnDisconnect(void) { delete this; return TRUE; }
f4ada568
GL
79
80 // To enable the compressor
81 void Compress(bool on);
0834112f 82
07e829dc
GRG
83protected:
84 wxSocketBase *m_sock;
85 wxSocketStream *m_sockstrm;
86 wxDataInputStream *m_codeci;
87 wxDataOutputStream *m_codeco;
88 wxString m_topic;
89
90 friend class wxTCPServer;
91 friend class wxTCPClient;
92 friend void Client_OnRequest(wxSocketBase&,
93 wxSocketNotify, char *);
94 friend void Server_OnRequest(wxSocketServer&,
95 wxSocketNotify, char *);
96
54da4255 97private:
4ca0f293
DW
98 //
99 // We're hiding an Execute method in ConnectionBase
100 //s
101 virtual bool Execute(const wxString& str)
102 { return Execute(str, -1, wxIPC_TEXT); }
f4ada568
GL
103};
104
105class wxTCPServer: public wxServerBase
106{
107 DECLARE_DYNAMIC_CLASS(wxTCPServer)
108
109public:
110 wxTCPConnection *topLevelConnection;
111
112 wxTCPServer();
113 virtual ~wxTCPServer();
54da4255 114
f4ada568 115 // Returns FALSE if can't create server (e.g. port number is already in use)
54da4255 116 virtual bool Create(const wxString& server_name);
f4ada568
GL
117 virtual wxConnectionBase *OnAcceptConnection(const wxString& topic);
118};
119
120class wxTCPClient: public wxClientBase
121{
122 DECLARE_DYNAMIC_CLASS(wxTCPClient)
123
54da4255 124public:
f4ada568
GL
125 wxTCPClient();
126 virtual ~wxTCPClient();
127
128 virtual bool ValidHost(const wxString& host);
0834112f
GRG
129 // Call this to make a connection.
130 // Returns NULL if cannot.
f4ada568
GL
131 virtual wxConnectionBase *MakeConnection(const wxString& host,
132 const wxString& server,
133 const wxString& topic);
54da4255 134
f4ada568
GL
135 // Tailor this to return own connection.
136 virtual wxConnectionBase *OnMakeConnection();
137};
138
139#endif // ipcsock.h