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