]> git.saurik.com Git - wxWidgets.git/blame - include/wx/unix/gsockunx.h
Empty container and design description for native PalmOS wxPrefConfig. Remove MSW...
[wxWidgets.git] / include / wx / unix / gsockunx.h
CommitLineData
dbd300df
GL
1/* -------------------------------------------------------------------------
2 * Project: GSocket (Generic Socket) for WX
3 * Name: gsockunx.h
4 * Purpose: GSocket Unix header
5 * CVSID: $Id$
6 * -------------------------------------------------------------------------
7 */
483249fc 8
a324a7bc
GL
9#ifndef __GSOCK_UNX_H
10#define __GSOCK_UNX_H
11
483249fc 12#ifndef __GSOCKET_STANDALONE__
d422d01e 13#include "wx/setup.h"
483249fc 14#endif
d422d01e 15
483249fc 16#if wxUSE_SOCKETS || defined(__GSOCKET_STANDALONE__)
d422d01e 17
483249fc 18#ifndef __GSOCKET_STANDALONE__
d422d01e 19#include "wx/gsocket.h"
483249fc
GRG
20#else
21#include "gsocket.h"
22#endif
23
ba2a81d7 24class GSocketGUIFunctionsTableConcrete: public GSocketGUIFunctionsTable
09e6e5ec
DE
25{
26public:
ba2a81d7
DE
27 virtual bool OnInit();
28 virtual void OnExit();
29 virtual bool CanUseEventLoop();
30 virtual bool Init_Socket(GSocket *socket);
31 virtual void Destroy_Socket(GSocket *socket);
32 virtual void Install_Callback(GSocket *socket, GSocketEvent event);
33 virtual void Uninstall_Callback(GSocket *socket, GSocketEvent event);
34 virtual void Enable_Events(GSocket *socket);
35 virtual void Disable_Events(GSocket *socket);
36};
ba2a81d7 37
ba2a81d7
DE
38class GSocket
39{
40public:
41 GSocket();
42 virtual ~GSocket();
09e6e5ec
DE
43 bool IsOk() { return m_ok; }
44 void Close();
45 void Shutdown();
46 GSocketError SetLocal(GAddress *address);
47 GSocketError SetPeer(GAddress *address);
48 GAddress *GetLocal();
49 GAddress *GetPeer();
50 GSocketError SetServer();
51 GSocket *WaitConnection();
948c96ef 52 bool SetReusable();
09e6e5ec
DE
53 GSocketError Connect(GSocketStream stream);
54 GSocketError SetNonOriented();
55 int Read(char *buffer, int size);
56 int Write(const char *buffer, int size);
57 GSocketEventFlags Select(GSocketEventFlags flags);
948c96ef 58 void SetNonBlocking(bool non_block);
09e6e5ec 59 void SetTimeout(unsigned long millisec);
ba2a81d7 60 GSocketError WXDLLIMPEXP_NET GetError();
09e6e5ec
DE
61 void SetCallback(GSocketEventFlags flags,
62 GSocketCallback callback, char *cdata);
63 void UnsetCallback(GSocketEventFlags flags);
b082b524
DE
64 GSocketError GetSockOpt(int level, int optname, void *optval, int *optlen);
65 GSocketError SetSockOpt(int level, int optname,
66 const void *optval, int optlen);
ba2a81d7
DE
67 virtual void Detected_Read();
68 virtual void Detected_Write();
09e6e5ec
DE
69protected:
70 void Enable(GSocketEvent event);
71 void Disable(GSocketEvent event);
72 GSocketError Input_Timeout();
73 GSocketError Output_Timeout();
74 int Recv_Stream(char *buffer, int size);
75 int Recv_Dgram(char *buffer, int size);
76 int Send_Stream(const char *buffer, int size);
77 int Send_Dgram(const char *buffer, int size);
09e6e5ec
DE
78 bool m_ok;
79public:
b6db2e91
SN
80 /* DFE: We can't protect these data member until the GUI code is updated */
81 /* protected: */
a324a7bc 82 int m_fd;
483249fc
GRG
83 GAddress *m_local;
84 GAddress *m_peer;
a324a7bc
GL
85 GSocketError m_error;
86
948c96ef
DE
87 bool m_non_blocking;
88 bool m_server;
89 bool m_stream;
90 bool m_establishing;
91 bool m_reusable;
39b91eca 92 unsigned long m_timeout;
a324a7bc 93
39b91eca 94 /* Callbacks */
483249fc 95 GSocketEventFlags m_detected;
98781fa3 96 GSocketCallback m_cbacks[GSOCK_MAX_EVENT];
a324a7bc
GL
97 char *m_data[GSOCK_MAX_EVENT];
98
a324a7bc 99 char *m_gui_dependent;
38bb138f 100
a324a7bc
GL
101};
102
09e6e5ec
DE
103#ifdef __cplusplus
104extern "C" {
105#endif /* __cplusplus */
a324a7bc 106/* Definition of GAddress */
483249fc
GRG
107struct _GAddress
108{
a324a7bc
GL
109 struct sockaddr *m_addr;
110 size_t m_len;
111
112 GAddressType m_family;
113 int m_realfamily;
114
115 GSocketError m_error;
116};
09e6e5ec
DE
117#ifdef __cplusplus
118}
119#endif /* __cplusplus */
120
09e6e5ec
DE
121
122#ifdef __cplusplus
123extern "C" {
124#endif /* __cplusplus */
a324a7bc 125
5ff86996 126
483249fc 127/* GAddress */
e00f35bb 128
54e575f9
GL
129GSocketError _GAddress_translate_from(GAddress *address,
130 struct sockaddr *addr, int len);
9bf10d6b
GRG
131GSocketError _GAddress_translate_to (GAddress *address,
132 struct sockaddr **addr, int *len);
54e575f9 133GSocketError _GAddress_Init_INET(GAddress *address);
54e575f9 134GSocketError _GAddress_Init_UNIX(GAddress *address);
a324a7bc 135
9bf10d6b 136
d422d01e
RR
137#ifdef __cplusplus
138}
483249fc 139#endif /* __cplusplus */
d422d01e 140
483249fc 141#endif /* wxUSE_SOCKETS || defined(__GSOCKET_STANDALONE__) */
d422d01e 142
483249fc 143#endif /* __GSOCK_UNX_H */