]> git.saurik.com Git - wxWidgets.git/blame - include/wx/msw/gsockmsw.h
Get rid of inline C compatibility methods
[wxWidgets.git] / include / wx / msw / gsockmsw.h
CommitLineData
904ec517
GRG
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
0ce742cf
GRG
12#ifndef __GSOCKET_STANDALONE__
13#include "wx/setup.h"
14#endif
15
16#if wxUSE_SOCKETS || defined(__GSOCKET_STANDALONE__)
17
c21b68f7 18#ifndef __GSOCKET_STANDALONE__
904ec517
GRG
19#include "wx/gsocket.h"
20#else
21#include "gsocket.h"
22#endif
23
4b4d23c7 24#include "wx/msw/wrapwin.h"
c21b68f7 25
5c9eff30
GRG
26#ifndef TRUE
27#define TRUE 1
28#endif
29
30#ifndef FALSE
31#define FALSE 0
32#endif
33
4b4d23c7
DE
34class GSocketGUIFunctionsTableConcrete: public GSocketGUIFunctionsTable
35{
36public:
37 virtual bool OnInit();
38 virtual void OnExit();
39 virtual bool CanUseEventLoop();
40 virtual bool Init_Socket(GSocket *socket);
41 virtual void Destroy_Socket(GSocket *socket);
42 virtual void Enable_Events(GSocket *socket);
43 virtual void Disable_Events(GSocket *socket);
44};
4b4d23c7 45
904ec517 46/* Definition of GSocket */
4b4d23c7 47class GSocket
904ec517 48{
4b4d23c7
DE
49public:
50 GSocket();
51 ~GSocket();
52 bool IsOk() { return m_ok; }
53 void Close();
54 void Shutdown();
55 GSocketError SetLocal(GAddress *address);
56 GSocketError SetPeer(GAddress *address);
57 GAddress *GetLocal();
58 GAddress *GetPeer();
59 GSocketError SetServer();
60 GSocket *WaitConnection();
61 int SetReusable();
62 GSocketError Connect(GSocketStream stream);
63 GSocketError SetNonOriented();
64 int Read(char *buffer, int size);
65 int Write(const char *buffer, int size);
66 GSocketEventFlags Select(GSocketEventFlags flags);
67 void SetNonBlocking(bool non_block);
68 void SetTimeout(unsigned long millis);
a4506848 69 GSocketError WXDLLIMPEXP_NET GetError();
4b4d23c7
DE
70 void SetCallback(GSocketEventFlags flags,
71 GSocketCallback callback, char *cdata);
72 void UnsetCallback(GSocketEventFlags flags);
73 GSocketError GetSockOpt(int level, int optname,
74 void *optval, int *optlen);
75 GSocketError SetSockOpt(int level, int optname,
76 const void *optval, int optlen);
77protected:
78 GSocketError Input_Timeout();
79 GSocketError Output_Timeout();
80 GSocketError Connect_Timeout();
81 int Recv_Stream(char *buffer, int size);
82 int Recv_Dgram(char *buffer, int size);
83 int Send_Stream(const char *buffer, int size);
84 int Send_Dgram(const char *buffer, int size);
85 bool m_ok;
86
87/* TODO: Make these protected */
88public:
904ec517
GRG
89 SOCKET m_fd;
90 GAddress *m_local;
91 GAddress *m_peer;
92 GSocketError m_error;
93
483249fc 94 /* Attributes */
27a97d02
GRG
95 int m_non_blocking;
96 int m_server;
97 int m_stream;
27a97d02 98 int m_establishing;
74c481d1 99 int m_reusable;
904ec517
GRG
100 struct timeval m_timeout;
101
102 /* Callbacks */
483249fc 103 GSocketEventFlags m_detected;
904ec517
GRG
104 GSocketCallback m_cbacks[GSOCK_MAX_EVENT];
105 char *m_data[GSOCK_MAX_EVENT];
106 int m_msgnumber;
107};
108
4b4d23c7
DE
109#ifdef __cplusplus
110extern "C" {
111#endif
112
904ec517
GRG
113/* Definition of GAddress */
114struct _GAddress
115{
116 struct sockaddr *m_addr;
117 size_t m_len;
118
119 GAddressType m_family;
120 int m_realfamily;
121
122 GSocketError m_error;
123};
124
904ec517
GRG
125
126/* GAddress */
127
128GSocketError _GAddress_translate_from(GAddress *address,
129 struct sockaddr *addr, int len);
d3ea6527
GRG
130GSocketError _GAddress_translate_to (GAddress *address,
131 struct sockaddr **addr, int *len);
904ec517
GRG
132GSocketError _GAddress_Init_INET(GAddress *address);
133GSocketError _GAddress_Init_UNIX(GAddress *address);
134
135#ifdef __cplusplus
136}
137#endif
138
0ce742cf
GRG
139#endif /* wxUSE_SOCKETS || defined(__GSOCKET_STANDALONE__) */
140
904ec517 141#endif /* __GSOCK_MSW_H */