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