]> git.saurik.com Git - wxWidgets.git/blame_incremental - include/wx/unix/gsockunx.h
set eol-style
[wxWidgets.git] / include / wx / unix / gsockunx.h
... / ...
CommitLineData
1/* -------------------------------------------------------------------------
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$
8 * -------------------------------------------------------------------------
9 */
10
11#ifndef __GSOCK_UNX_H
12#define __GSOCK_UNX_H
13
14#ifndef __GSOCKET_STANDALONE__
15#include "wx/setup.h"
16#endif
17
18class wxGSocketIOHandler;
19
20#if wxUSE_SOCKETS || defined(__GSOCKET_STANDALONE__)
21
22#ifndef __GSOCKET_STANDALONE__
23#include "wx/gsocket.h"
24#else
25#include "gsocket.h"
26#endif
27
28class GSocketGUIFunctionsTableConcrete : public GSocketGUIFunctionsTable
29{
30public:
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};
41
42class GSocket
43{
44public:
45 GSocket();
46 virtual ~GSocket();
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();
56 bool SetReusable();
57 bool SetBroadcast();
58 bool DontDoBind();
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);
64 void SetNonBlocking(bool non_block);
65 void SetTimeout(unsigned long millisec);
66 GSocketError WXDLLIMPEXP_NET GetError();
67 void SetCallback(GSocketEventFlags flags,
68 GSocketCallback callback, char *cdata);
69 void UnsetCallback(GSocketEventFlags flags);
70 GSocketError GetSockOpt(int level, int optname, void *optval, int *optlen);
71 GSocketError SetSockOpt(int level, int optname,
72 const void *optval, int optlen);
73 virtual void Detected_Read();
74 virtual void Detected_Write();
75protected:
76 void Enable(GSocketEvent event);
77 void Disable(GSocketEvent event);
78 GSocketError Input_Timeout();
79 GSocketError Output_Timeout();
80 int Recv_Stream(char *buffer, int size);
81 int Recv_Dgram(char *buffer, int size);
82 int Send_Stream(const char *buffer, int size);
83 int Send_Dgram(const char *buffer, int size);
84 bool m_ok;
85public:
86 /* DFE: We can't protect these data member until the GUI code is updated */
87 /* protected: */
88 int m_fd;
89 wxGSocketIOHandler *m_handler;
90 GAddress *m_local;
91 GAddress *m_peer;
92 GSocketError m_error;
93
94 bool m_non_blocking;
95 bool m_server;
96 bool m_stream;
97 bool m_establishing;
98 bool m_reusable;
99 bool m_broadcast;
100 bool m_dobind;
101 unsigned long m_timeout;
102
103 /* Callbacks */
104 GSocketEventFlags m_detected;
105 GSocketCallback m_cbacks[GSOCK_MAX_EVENT];
106 char *m_data[GSOCK_MAX_EVENT];
107
108 char *m_gui_dependent;
109
110};
111
112#ifdef __cplusplus
113extern "C" {
114#endif /* __cplusplus */
115/* Definition of GAddress */
116struct _GAddress
117{
118 struct sockaddr *m_addr;
119 size_t m_len;
120
121 GAddressType m_family;
122 int m_realfamily;
123
124 GSocketError m_error;
125};
126#ifdef __cplusplus
127}
128#endif /* __cplusplus */
129
130
131#ifdef __cplusplus
132extern "C" {
133#endif /* __cplusplus */
134
135
136/* GAddress */
137
138GSocketError _GAddress_translate_from(GAddress *address,
139 struct sockaddr *addr, int len);
140GSocketError _GAddress_translate_to (GAddress *address,
141 struct sockaddr **addr, int *len);
142GSocketError _GAddress_Init_INET(GAddress *address);
143GSocketError _GAddress_Init_UNIX(GAddress *address);
144
145
146#ifdef __cplusplus
147}
148#endif /* __cplusplus */
149
150#endif /* wxUSE_SOCKETS || defined(__GSOCKET_STANDALONE__) */
151
152#endif /* __GSOCK_UNX_H */