]> git.saurik.com Git - wxWidgets.git/blame - include/wx/msw/gsockmsw.h
fix access to client data of wxComboBox in wxUniv by virtualizing access to wxControl...
[wxWidgets.git] / include / wx / msw / gsockmsw.h
CommitLineData
904ec517 1/* -------------------------------------------------------------------------
99d80019
JS
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$
904ec517
GRG
8 * -------------------------------------------------------------------------
9 */
10
11#ifndef __GSOCK_MSW_H
12#define __GSOCK_MSW_H
13
0ce742cf
GRG
14#ifndef __GSOCKET_STANDALONE__
15#include "wx/setup.h"
16#endif
17
18#if wxUSE_SOCKETS || defined(__GSOCKET_STANDALONE__)
19
c21b68f7 20#ifndef __GSOCKET_STANDALONE__
904ec517
GRG
21#include "wx/gsocket.h"
22#else
23#include "gsocket.h"
24#endif
25
4b4d23c7 26#include "wx/msw/wrapwin.h"
c21b68f7 27
9e07d399
RN
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__)
dbfb61b3
JS
35#include <winsock.h>
36#endif
37
4b4d23c7
DE
38class GSocketGUIFunctionsTableConcrete: public GSocketGUIFunctionsTable
39{
40public:
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};
4b4d23c7 49
904ec517 50/* Definition of GSocket */
4b4d23c7 51class GSocket
904ec517 52{
4b4d23c7
DE
53public:
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();
22b6de6a
VZ
65 // not used under MSW
66 void Notify(bool WXUNUSED(enable)) { }
948c96ef 67 bool SetReusable();
60edcf45
VZ
68 bool SetBroadcast();
69 bool DontDoBind();
4b4d23c7
DE
70 GSocketError Connect(GSocketStream stream);
71 GSocketError SetNonOriented();
72 int Read(char *buffer, int size);
73 int Write(const char *buffer, int size);
74 GSocketEventFlags Select(GSocketEventFlags flags);
75 void SetNonBlocking(bool non_block);
76 void SetTimeout(unsigned long millis);
a4506848 77 GSocketError WXDLLIMPEXP_NET GetError();
4b4d23c7
DE
78 void SetCallback(GSocketEventFlags flags,
79 GSocketCallback callback, char *cdata);
80 void UnsetCallback(GSocketEventFlags flags);
81 GSocketError GetSockOpt(int level, int optname,
82 void *optval, int *optlen);
83 GSocketError SetSockOpt(int level, int optname,
84 const void *optval, int optlen);
85protected:
86 GSocketError Input_Timeout();
87 GSocketError Output_Timeout();
88 GSocketError Connect_Timeout();
89 int Recv_Stream(char *buffer, int size);
90 int Recv_Dgram(char *buffer, int size);
91 int Send_Stream(const char *buffer, int size);
92 int Send_Dgram(const char *buffer, int size);
93 bool m_ok;
94
95/* TODO: Make these protected */
96public:
904ec517
GRG
97 SOCKET m_fd;
98 GAddress *m_local;
99 GAddress *m_peer;
100 GSocketError m_error;
101
483249fc 102 /* Attributes */
948c96ef
DE
103 bool m_non_blocking;
104 bool m_server;
105 bool m_stream;
106 bool m_establishing;
107 bool m_reusable;
60edcf45
VZ
108 bool m_broadcast;
109 bool m_dobind;
904ec517
GRG
110 struct timeval m_timeout;
111
112 /* Callbacks */
483249fc 113 GSocketEventFlags m_detected;
904ec517
GRG
114 GSocketCallback m_cbacks[GSOCK_MAX_EVENT];
115 char *m_data[GSOCK_MAX_EVENT];
116 int m_msgnumber;
117};
118
4b4d23c7
DE
119#ifdef __cplusplus
120extern "C" {
121#endif
122
904ec517
GRG
123/* Definition of GAddress */
124struct _GAddress
125{
126 struct sockaddr *m_addr;
127 size_t m_len;
128
129 GAddressType m_family;
130 int m_realfamily;
131
132 GSocketError m_error;
133};
134
904ec517
GRG
135
136/* GAddress */
137
138GSocketError _GAddress_translate_from(GAddress *address,
139 struct sockaddr *addr, int len);
d3ea6527
GRG
140GSocketError _GAddress_translate_to (GAddress *address,
141 struct sockaddr **addr, int *len);
904ec517
GRG
142GSocketError _GAddress_Init_INET(GAddress *address);
143GSocketError _GAddress_Init_UNIX(GAddress *address);
144
145#ifdef __cplusplus
146}
147#endif
148
0ce742cf
GRG
149#endif /* wxUSE_SOCKETS || defined(__GSOCKET_STANDALONE__) */
150
904ec517 151#endif /* __GSOCK_MSW_H */