]> git.saurik.com Git - wxWidgets.git/blame - include/wx/unix/gsockunx.h
reuse operator bool() check in compatibility_iterator::IndexOf() instead of rewriting it
[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();
09e6e5ec
DE
55 GSocketError Connect(GSocketStream stream);
56 GSocketError SetNonOriented();
57 int Read(char *buffer, int size);
58 int Write(const char *buffer, int size);
59 GSocketEventFlags Select(GSocketEventFlags flags);
948c96ef 60 void SetNonBlocking(bool non_block);
09e6e5ec 61 void SetTimeout(unsigned long millisec);
ba2a81d7 62 GSocketError WXDLLIMPEXP_NET GetError();
09e6e5ec
DE
63 void SetCallback(GSocketEventFlags flags,
64 GSocketCallback callback, char *cdata);
65 void UnsetCallback(GSocketEventFlags flags);
b082b524
DE
66 GSocketError GetSockOpt(int level, int optname, void *optval, int *optlen);
67 GSocketError SetSockOpt(int level, int optname,
68 const void *optval, int optlen);
ba2a81d7
DE
69 virtual void Detected_Read();
70 virtual void Detected_Write();
09e6e5ec
DE
71protected:
72 void Enable(GSocketEvent event);
73 void Disable(GSocketEvent event);
74 GSocketError Input_Timeout();
75 GSocketError Output_Timeout();
76 int Recv_Stream(char *buffer, int size);
77 int Recv_Dgram(char *buffer, int size);
78 int Send_Stream(const char *buffer, int size);
79 int Send_Dgram(const char *buffer, int size);
09e6e5ec
DE
80 bool m_ok;
81public:
b6db2e91
SN
82 /* DFE: We can't protect these data member until the GUI code is updated */
83 /* protected: */
a324a7bc 84 int m_fd;
483249fc
GRG
85 GAddress *m_local;
86 GAddress *m_peer;
a324a7bc
GL
87 GSocketError m_error;
88
948c96ef
DE
89 bool m_non_blocking;
90 bool m_server;
91 bool m_stream;
92 bool m_establishing;
93 bool m_reusable;
39b91eca 94 unsigned long m_timeout;
a324a7bc 95
39b91eca 96 /* Callbacks */
483249fc 97 GSocketEventFlags m_detected;
98781fa3 98 GSocketCallback m_cbacks[GSOCK_MAX_EVENT];
a324a7bc
GL
99 char *m_data[GSOCK_MAX_EVENT];
100
a324a7bc 101 char *m_gui_dependent;
38bb138f 102
a324a7bc
GL
103};
104
09e6e5ec
DE
105#ifdef __cplusplus
106extern "C" {
107#endif /* __cplusplus */
a324a7bc 108/* Definition of GAddress */
483249fc
GRG
109struct _GAddress
110{
a324a7bc
GL
111 struct sockaddr *m_addr;
112 size_t m_len;
113
114 GAddressType m_family;
115 int m_realfamily;
116
117 GSocketError m_error;
118};
09e6e5ec
DE
119#ifdef __cplusplus
120}
121#endif /* __cplusplus */
122
09e6e5ec
DE
123
124#ifdef __cplusplus
125extern "C" {
126#endif /* __cplusplus */
a324a7bc 127
5ff86996 128
483249fc 129/* GAddress */
e00f35bb 130
54e575f9
GL
131GSocketError _GAddress_translate_from(GAddress *address,
132 struct sockaddr *addr, int len);
9bf10d6b
GRG
133GSocketError _GAddress_translate_to (GAddress *address,
134 struct sockaddr **addr, int *len);
54e575f9 135GSocketError _GAddress_Init_INET(GAddress *address);
54e575f9 136GSocketError _GAddress_Init_UNIX(GAddress *address);
a324a7bc 137
9bf10d6b 138
d422d01e
RR
139#ifdef __cplusplus
140}
483249fc 141#endif /* __cplusplus */
d422d01e 142
483249fc 143#endif /* wxUSE_SOCKETS || defined(__GSOCKET_STANDALONE__) */
d422d01e 144
483249fc 145#endif /* __GSOCK_UNX_H */