]> git.saurik.com Git - wxWidgets.git/blob - include/wx/unix/gsockunx.h
Native spline drawing.
[wxWidgets.git] / include / wx / unix / gsockunx.h
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
18 #if wxUSE_SOCKETS || defined(__GSOCKET_STANDALONE__)
19
20 #ifndef __GSOCKET_STANDALONE__
21 #include "wx/gsocket.h"
22 #else
23 #include "gsocket.h"
24 #endif
25
26 class GSocketGUIFunctionsTableConcrete: public GSocketGUIFunctionsTable
27 {
28 public:
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 };
39
40 class GSocket
41 {
42 public:
43 GSocket();
44 virtual ~GSocket();
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();
54 bool SetReusable();
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);
60 void SetNonBlocking(bool non_block);
61 void SetTimeout(unsigned long millisec);
62 GSocketError WXDLLIMPEXP_NET GetError();
63 void SetCallback(GSocketEventFlags flags,
64 GSocketCallback callback, char *cdata);
65 void UnsetCallback(GSocketEventFlags flags);
66 GSocketError GetSockOpt(int level, int optname, void *optval, int *optlen);
67 GSocketError SetSockOpt(int level, int optname,
68 const void *optval, int optlen);
69 virtual void Detected_Read();
70 virtual void Detected_Write();
71 protected:
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);
80 bool m_ok;
81 public:
82 /* DFE: We can't protect these data member until the GUI code is updated */
83 /* protected: */
84 int m_fd;
85 GAddress *m_local;
86 GAddress *m_peer;
87 GSocketError m_error;
88
89 bool m_non_blocking;
90 bool m_server;
91 bool m_stream;
92 bool m_establishing;
93 bool m_reusable;
94 unsigned long m_timeout;
95
96 /* Callbacks */
97 GSocketEventFlags m_detected;
98 GSocketCallback m_cbacks[GSOCK_MAX_EVENT];
99 char *m_data[GSOCK_MAX_EVENT];
100
101 char *m_gui_dependent;
102
103 };
104
105 #ifdef __cplusplus
106 extern "C" {
107 #endif /* __cplusplus */
108 /* Definition of GAddress */
109 struct _GAddress
110 {
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 };
119 #ifdef __cplusplus
120 }
121 #endif /* __cplusplus */
122
123
124 #ifdef __cplusplus
125 extern "C" {
126 #endif /* __cplusplus */
127
128
129 /* GAddress */
130
131 GSocketError _GAddress_translate_from(GAddress *address,
132 struct sockaddr *addr, int len);
133 GSocketError _GAddress_translate_to (GAddress *address,
134 struct sockaddr **addr, int *len);
135 GSocketError _GAddress_Init_INET(GAddress *address);
136 GSocketError _GAddress_Init_UNIX(GAddress *address);
137
138
139 #ifdef __cplusplus
140 }
141 #endif /* __cplusplus */
142
143 #endif /* wxUSE_SOCKETS || defined(__GSOCKET_STANDALONE__) */
144
145 #endif /* __GSOCK_UNX_H */