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