]> git.saurik.com Git - wxWidgets.git/blame - include/wx/sckipc.h
Rotated text patch from Hans-Joachim Baader (with some corrections)
[wxWidgets.git] / include / wx / sckipc.h
CommitLineData
f4ada568
GL
1/////////////////////////////////////////////////////////////////////////////
2// Name: sckipc.h
3// Purpose: Interprocess communication
4// Author: Julian Smart/Guilhem Lavaux (big rewrite)
5// Modified by: Guilhem Lavaux 1997
6// Created: 1993
7// RCS-ID: $Id$
8// Copyright: (c) 1993 Julian Smart
9// (c) 1997, 1998 Guilhem Lavaux
10// Licence: wxWindows license
11/////////////////////////////////////////////////////////////////////////////
12#ifndef _WX_SCKIPC_H
13#define _WX_SCKIPC_H
14
15#ifdef __GNUG__
16#pragma interface
17#endif
18
19#include "wx/defs.h"
20#include "wx/setup.h"
21#include "wx/ipcbase.h"
22#include "wx/socket.h"
23#include "wx/sckstrm.h"
24#include "wx/datstrm.h"
25
26/*
27 * Mini-DDE implementation
28
29 Most transactions involve a topic name and an item name (choose these
30 as befits your application).
31
32 A client can:
33
34 - ask the server to execute commands (data) associated with a topic
35 - request data from server by topic and item
36 - poke data into the server
37 - ask the server to start an advice loop on topic/item
38 - ask the server to stop an advice loop
39
40 A server can:
41
42 - respond to execute, request, poke and advice start/stop
43 - send advise data to client
44
45 Note that this limits the server in the ways it can send data to the
46 client, i.e. it can't send unsolicited information.
47 *
48 */
49
50class wxTCPServer;
51class wxTCPClient;
52class wxTCPConnection: public wxConnectionBase
53{
54 DECLARE_DYNAMIC_CLASS(wxTCPConnection)
54da4255 55
f4ada568
GL
56protected:
57 wxSocketBase *m_sock;
58 wxSocketStream *m_sockstrm;
75ed1d15
GL
59 wxDataInputStream *m_codeci;
60 wxDataOutputStream *m_codeco;
f4ada568
GL
61 wxString m_topic;
62
63 friend class wxTCPServer;
64 friend class wxTCPClient;
65 friend void Client_OnRequest(wxSocketBase&,
e90c1d2a 66 wxSocketNotify, char *);
f4ada568 67 friend void Server_OnRequest(wxSocketServer&,
e90c1d2a 68 wxSocketNotify, char *);
f4ada568
GL
69public:
70
71 wxTCPConnection(char *buffer, int size);
72 wxTCPConnection();
73 virtual ~wxTCPConnection();
74
75 // Calls that CLIENT can make
e90c1d2a 76 bool Execute(const wxChar *data, int size = -1,
0d2a2b60 77 wxIPCFormat format = wxIPC_TEXT);
f4ada568 78 char *Request(const wxString& item, int *size = NULL,
0d2a2b60 79 wxIPCFormat format = wxIPC_TEXT);
2ed57eb7 80 bool Poke(const wxString& item, wxChar *data, int size = -1,
0d2a2b60 81 wxIPCFormat format = wxIPC_TEXT);
f4ada568
GL
82 bool StartAdvise(const wxString& item);
83 bool StopAdvise(const wxString& item);
84
85 // Calls that SERVER can make
2ed57eb7 86 bool Advise(const wxString& item, wxChar *data, int size = -1,
0d2a2b60 87 wxIPCFormat format = wxIPC_TEXT);
f4ada568
GL
88
89 // Calls that both can make
90 bool Disconnect();
91
92 // Called when we lost the peer.
93 bool OnDisconnect() { return TRUE; }
94
95 // To enable the compressor
96 void Compress(bool on);
54da4255
DW
97private:
98 // to prevent virtual function hiding warnings
99 virtual bool Execute(const wxString& str) { return(wxConnectionBase::Execute(str)); };
f4ada568
GL
100};
101
102class wxTCPServer: public wxServerBase
103{
104 DECLARE_DYNAMIC_CLASS(wxTCPServer)
105
106public:
107 wxTCPConnection *topLevelConnection;
108
109 wxTCPServer();
110 virtual ~wxTCPServer();
54da4255 111
f4ada568 112 // Returns FALSE if can't create server (e.g. port number is already in use)
54da4255 113 virtual bool Create(const wxString& server_name);
f4ada568
GL
114 virtual wxConnectionBase *OnAcceptConnection(const wxString& topic);
115};
116
117class wxTCPClient: public wxClientBase
118{
119 DECLARE_DYNAMIC_CLASS(wxTCPClient)
120
54da4255 121public:
f4ada568
GL
122 wxTCPClient();
123 virtual ~wxTCPClient();
124
125 virtual bool ValidHost(const wxString& host);
126 // Call this to make a connection.
127 // Returns NULL if cannot.
128 virtual wxConnectionBase *MakeConnection(const wxString& host,
129 const wxString& server,
130 const wxString& topic);
54da4255 131
f4ada568
GL
132 // Tailor this to return own connection.
133 virtual wxConnectionBase *OnMakeConnection();
134};
135
136#endif // ipcsock.h