]> git.saurik.com Git - wxWidgets.git/blob - include/wx/msw/gsockmsw.h
show the function in which the assert failure occured if the compiler supports it
[wxWidgets.git] / include / wx / msw / gsockmsw.h
1 /* -------------------------------------------------------------------------
2 * Project: GSocket (Generic Socket) for WX
3 * Name: gsockmsw.h
4 * Copyright: (c) Guilhem Lavaux
5 * Licence: wxWindows Licence
6 * Purpose: GSocket MSW header
7 * CVSID: $Id$
8 * -------------------------------------------------------------------------
9 */
10
11 #ifndef __GSOCK_MSW_H
12 #define __GSOCK_MSW_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 #include "wx/msw/wrapwin.h"
27
28 #if defined(__CYGWIN__)
29 //CYGWIN gives annoying warning about runtime stuff if we don't do this
30 # define USE_SYS_TYPES_FD_SET
31 # include <sys/types.h>
32 #endif
33
34 #if defined(__WXWINCE__) || defined(__CYGWIN__)
35 #include <winsock.h>
36 #endif
37
38 class GSocketGUIFunctionsTableConcrete: public GSocketGUIFunctionsTable
39 {
40 public:
41 virtual bool OnInit();
42 virtual void OnExit();
43 virtual bool CanUseEventLoop();
44 virtual bool Init_Socket(GSocket *socket);
45 virtual void Destroy_Socket(GSocket *socket);
46 virtual void Enable_Events(GSocket *socket);
47 virtual void Disable_Events(GSocket *socket);
48 };
49
50 /* Definition of GSocket */
51 class GSocket
52 {
53 public:
54 GSocket();
55 ~GSocket();
56 bool IsOk() { return m_ok; }
57 void Close();
58 void Shutdown();
59 GSocketError SetLocal(GAddress *address);
60 GSocketError SetPeer(GAddress *address);
61 GAddress *GetLocal();
62 GAddress *GetPeer();
63 GSocketError SetServer();
64 GSocket *WaitConnection();
65 bool SetReusable();
66 GSocketError Connect(GSocketStream stream);
67 GSocketError SetNonOriented();
68 int Read(char *buffer, int size);
69 int Write(const char *buffer, int size);
70 GSocketEventFlags Select(GSocketEventFlags flags);
71 void SetNonBlocking(bool non_block);
72 void SetTimeout(unsigned long millis);
73 GSocketError WXDLLIMPEXP_NET GetError();
74 void SetCallback(GSocketEventFlags flags,
75 GSocketCallback callback, char *cdata);
76 void UnsetCallback(GSocketEventFlags flags);
77 GSocketError GetSockOpt(int level, int optname,
78 void *optval, int *optlen);
79 GSocketError SetSockOpt(int level, int optname,
80 const void *optval, int optlen);
81 protected:
82 GSocketError Input_Timeout();
83 GSocketError Output_Timeout();
84 GSocketError Connect_Timeout();
85 int Recv_Stream(char *buffer, int size);
86 int Recv_Dgram(char *buffer, int size);
87 int Send_Stream(const char *buffer, int size);
88 int Send_Dgram(const char *buffer, int size);
89 bool m_ok;
90
91 /* TODO: Make these protected */
92 public:
93 SOCKET m_fd;
94 GAddress *m_local;
95 GAddress *m_peer;
96 GSocketError m_error;
97
98 /* Attributes */
99 bool m_non_blocking;
100 bool m_server;
101 bool m_stream;
102 bool m_establishing;
103 bool m_reusable;
104 struct timeval m_timeout;
105
106 /* Callbacks */
107 GSocketEventFlags m_detected;
108 GSocketCallback m_cbacks[GSOCK_MAX_EVENT];
109 char *m_data[GSOCK_MAX_EVENT];
110 int m_msgnumber;
111 };
112
113 #ifdef __cplusplus
114 extern "C" {
115 #endif
116
117 /* Definition of GAddress */
118 struct _GAddress
119 {
120 struct sockaddr *m_addr;
121 size_t m_len;
122
123 GAddressType m_family;
124 int m_realfamily;
125
126 GSocketError m_error;
127 };
128
129
130 /* GAddress */
131
132 GSocketError _GAddress_translate_from(GAddress *address,
133 struct sockaddr *addr, int len);
134 GSocketError _GAddress_translate_to (GAddress *address,
135 struct sockaddr **addr, int *len);
136 GSocketError _GAddress_Init_INET(GAddress *address);
137 GSocketError _GAddress_Init_UNIX(GAddress *address);
138
139 #ifdef __cplusplus
140 }
141 #endif
142
143 #endif /* wxUSE_SOCKETS || defined(__GSOCKET_STANDALONE__) */
144
145 #endif /* __GSOCK_MSW_H */