]> git.saurik.com Git - wxWidgets.git/blob - include/wx/msw/gsockmsw.h
Script updates
[wxWidgets.git] / include / wx / msw / gsockmsw.h
1 /* -------------------------------------------------------------------------
2 * Project: GSocket (Generic Socket) for WX
3 * Name: gsockmsw.h
4 * Purpose: GSocket MSW header
5 * CVSID: $Id$
6 * -------------------------------------------------------------------------
7 */
8
9 #ifndef __GSOCK_MSW_H
10 #define __GSOCK_MSW_H
11
12 #ifndef __GSOCKET_STANDALONE__
13 #include "wx/setup.h"
14 #endif
15
16 #if wxUSE_SOCKETS || defined(__GSOCKET_STANDALONE__)
17
18 #ifndef __GSOCKET_STANDALONE__
19 #include "wx/gsocket.h"
20 #else
21 #include "gsocket.h"
22 #endif
23
24 #include "wx/msw/wrapwin.h"
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 Enable_Events(GSocket *socket);
35 virtual void Disable_Events(GSocket *socket);
36 };
37
38 /* Definition of GSocket */
39 class GSocket
40 {
41 public:
42 GSocket();
43 ~GSocket();
44 bool IsOk() { return m_ok; }
45 void Close();
46 void Shutdown();
47 GSocketError SetLocal(GAddress *address);
48 GSocketError SetPeer(GAddress *address);
49 GAddress *GetLocal();
50 GAddress *GetPeer();
51 GSocketError SetServer();
52 GSocket *WaitConnection();
53 bool SetReusable();
54 GSocketError Connect(GSocketStream stream);
55 GSocketError SetNonOriented();
56 int Read(char *buffer, int size);
57 int Write(const char *buffer, int size);
58 GSocketEventFlags Select(GSocketEventFlags flags);
59 void SetNonBlocking(bool non_block);
60 void SetTimeout(unsigned long millis);
61 GSocketError WXDLLIMPEXP_NET GetError();
62 void SetCallback(GSocketEventFlags flags,
63 GSocketCallback callback, char *cdata);
64 void UnsetCallback(GSocketEventFlags flags);
65 GSocketError GetSockOpt(int level, int optname,
66 void *optval, int *optlen);
67 GSocketError SetSockOpt(int level, int optname,
68 const void *optval, int optlen);
69 protected:
70 GSocketError Input_Timeout();
71 GSocketError Output_Timeout();
72 GSocketError Connect_Timeout();
73 int Recv_Stream(char *buffer, int size);
74 int Recv_Dgram(char *buffer, int size);
75 int Send_Stream(const char *buffer, int size);
76 int Send_Dgram(const char *buffer, int size);
77 bool m_ok;
78
79 /* TODO: Make these protected */
80 public:
81 SOCKET m_fd;
82 GAddress *m_local;
83 GAddress *m_peer;
84 GSocketError m_error;
85
86 /* Attributes */
87 bool m_non_blocking;
88 bool m_server;
89 bool m_stream;
90 bool m_establishing;
91 bool m_reusable;
92 struct timeval m_timeout;
93
94 /* Callbacks */
95 GSocketEventFlags m_detected;
96 GSocketCallback m_cbacks[GSOCK_MAX_EVENT];
97 char *m_data[GSOCK_MAX_EVENT];
98 int m_msgnumber;
99 };
100
101 #ifdef __cplusplus
102 extern "C" {
103 #endif
104
105 /* Definition of GAddress */
106 struct _GAddress
107 {
108 struct sockaddr *m_addr;
109 size_t m_len;
110
111 GAddressType m_family;
112 int m_realfamily;
113
114 GSocketError m_error;
115 };
116
117
118 /* GAddress */
119
120 GSocketError _GAddress_translate_from(GAddress *address,
121 struct sockaddr *addr, int len);
122 GSocketError _GAddress_translate_to (GAddress *address,
123 struct sockaddr **addr, int *len);
124 GSocketError _GAddress_Init_INET(GAddress *address);
125 GSocketError _GAddress_Init_UNIX(GAddress *address);
126
127 #ifdef __cplusplus
128 }
129 #endif
130
131 #endif /* wxUSE_SOCKETS || defined(__GSOCKET_STANDALONE__) */
132
133 #endif /* __GSOCK_MSW_H */