]>
git.saurik.com Git - wxWidgets.git/blob - include/wx/sckipc.h
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Interprocess communication
4 // Author: Julian Smart/Guilhem Lavaux (big rewrite)
5 // Modified by: Guilhem Lavaux 1997
8 // Copyright: (c) 1993 Julian Smart
9 // (c) 1997, 1998 Guilhem Lavaux
10 // Licence: wxWindows license
11 /////////////////////////////////////////////////////////////////////////////
21 #include "wx/ipcbase.h"
22 #include "wx/socket.h"
23 #include "wx/sckstrm.h"
24 #include "wx/datstrm.h"
27 * Mini-DDE implementation
29 Most transactions involve a topic name and an item name (choose these
30 as befits your application).
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
42 - respond to execute, request, poke and advice start/stop
43 - send advise data to client
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.
52 class wxTCPConnection
: public wxConnectionBase
54 DECLARE_DYNAMIC_CLASS(wxTCPConnection
)
58 wxSocketStream
*m_sockstrm
;
59 wxDataInputStream
*m_codeci
;
60 wxDataOutputStream
*m_codeco
;
63 friend class wxTCPServer
;
64 friend class wxTCPClient
;
65 friend void Client_OnRequest(wxSocketBase
&,
66 wxSocketBase::wxRequestEvent
, char *);
67 friend void Server_OnRequest(wxSocketServer
&,
68 wxSocketBase::wxRequestEvent
, char *);
71 wxTCPConnection(char *buffer
, int size
);
73 virtual ~wxTCPConnection();
75 // Calls that CLIENT can make
76 bool Execute(char *data
, int size
= -1,
77 wxIPCFormat format
= wxIPC_TEXT
);
78 char *Request(const wxString
& item
, int *size
= NULL
,
79 wxIPCFormat format
= wxIPC_TEXT
);
80 bool Poke(const wxString
& item
, char *data
, int size
= -1,
81 wxIPCFormat format
= wxIPC_TEXT
);
82 bool StartAdvise(const wxString
& item
);
83 bool StopAdvise(const wxString
& item
);
85 // Calls that SERVER can make
86 bool Advise(const wxString
& item
, char *data
, int size
= -1,
87 wxIPCFormat format
= wxIPC_TEXT
);
89 // Calls that both can make
92 // Called when we lost the peer.
93 bool OnDisconnect() { return TRUE
; }
95 // To enable the compressor
96 void Compress(bool on
);
99 class wxTCPServer
: public wxServerBase
101 DECLARE_DYNAMIC_CLASS(wxTCPServer
)
104 wxTCPConnection
*topLevelConnection
;
107 virtual ~wxTCPServer();
109 // Returns FALSE if can't create server (e.g. port number is already in use)
110 virtual bool Create(const wxString
& server_name
);
111 virtual wxConnectionBase
*OnAcceptConnection(const wxString
& topic
);
114 class wxTCPClient
: public wxClientBase
116 DECLARE_DYNAMIC_CLASS(wxTCPClient
)
120 virtual ~wxTCPClient();
122 virtual bool ValidHost(const wxString
& host
);
123 // Call this to make a connection.
124 // Returns NULL if cannot.
125 virtual wxConnectionBase
*MakeConnection(const wxString
& host
,
126 const wxString
& server
,
127 const wxString
& topic
);
129 // Tailor this to return own connection.
130 virtual wxConnectionBase
*OnMakeConnection();