]> git.saurik.com Git - wxWidgets.git/blame - include/wx/sckipc.h
Small oops in redrawing code.
[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>
f4ada568
GL
13// Licence: wxWindows license
14/////////////////////////////////////////////////////////////////////////////
07e829dc 15
f4ada568
GL
16#ifndef _WX_SCKIPC_H
17#define _WX_SCKIPC_H
18
19#ifdef __GNUG__
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
07e829dc
GRG
56class WXDLLEXPORT wxTCPServer;
57class WXDLLEXPORT wxTCPClient;
58
59class WXDLLEXPORT wxTCPConnection: public wxConnectionBase
f4ada568
GL
60{
61 DECLARE_DYNAMIC_CLASS(wxTCPConnection)
f4ada568 62public:
f4ada568
GL
63 wxTCPConnection(char *buffer, int size);
64 wxTCPConnection();
65 virtual ~wxTCPConnection();
66
67 // Calls that CLIENT can make
0834112f 68 virtual bool Execute(const wxChar *data, int size = -1, wxIPCFormat format = wxIPC_TEXT);
0834112f
GRG
69 virtual char *Request(const wxString& item, int *size = NULL, wxIPCFormat format = wxIPC_TEXT);
70 virtual bool Poke(const wxString& item, wxChar *data, int size = -1, wxIPCFormat format = wxIPC_TEXT);
71 virtual bool StartAdvise(const wxString& item);
72 virtual bool StopAdvise(const wxString& item);
f4ada568
GL
73
74 // Calls that SERVER can make
0834112f 75 virtual bool Advise(const wxString& item, wxChar *data, int size = -1, wxIPCFormat format = wxIPC_TEXT);
f4ada568
GL
76
77 // Calls that both can make
0834112f 78 virtual bool Disconnect(void);
f4ada568 79
0834112f
GRG
80 // Default behaviour is to delete connection and return TRUE
81 virtual bool OnDisconnect(void) { delete this; return TRUE; }
f4ada568
GL
82
83 // To enable the compressor
84 void Compress(bool on);
0834112f 85
07e829dc
GRG
86protected:
87 wxSocketBase *m_sock;
88 wxSocketStream *m_sockstrm;
89 wxDataInputStream *m_codeci;
90 wxDataOutputStream *m_codeco;
91 wxString m_topic;
92
93 friend class wxTCPServer;
94 friend class wxTCPClient;
cdc59bb6 95 friend class wxTCPEventHandler;
07e829dc 96
54da4255 97private:
4ca0f293
DW
98 //
99 // We're hiding an Execute method in ConnectionBase
cdc59bb6 100 //
4ca0f293 101 virtual bool Execute(const wxString& str)
cdc59bb6 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
cdc59bb6 139#endif // wxUSE_SOCKETS && wxUSE_IPC
26dfedc4 140
cdc59bb6 141#endif // _WX_SCKIPC_H