]> git.saurik.com Git - wxWidgets.git/blame - include/wx/msw/gsockmsw.h
add Length, Tell, SetPlaybackRate and GetPlaybackRate - use Connect instead of messag...
[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
4b4d23c7
DE
26class GSocketGUIFunctionsTableConcrete: public GSocketGUIFunctionsTable
27{
28public:
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};
4b4d23c7 37
904ec517 38/* Definition of GSocket */
4b4d23c7 39class GSocket
904ec517 40{
4b4d23c7
DE
41public:
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();
948c96ef 53 bool SetReusable();
4b4d23c7
DE
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);
a4506848 61 GSocketError WXDLLIMPEXP_NET GetError();
4b4d23c7
DE
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);
69protected:
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 */
80public:
904ec517
GRG
81 SOCKET m_fd;
82 GAddress *m_local;
83 GAddress *m_peer;
84 GSocketError m_error;
85
483249fc 86 /* Attributes */
948c96ef
DE
87 bool m_non_blocking;
88 bool m_server;
89 bool m_stream;
90 bool m_establishing;
91 bool m_reusable;
904ec517
GRG
92 struct timeval m_timeout;
93
94 /* Callbacks */
483249fc 95 GSocketEventFlags m_detected;
904ec517
GRG
96 GSocketCallback m_cbacks[GSOCK_MAX_EVENT];
97 char *m_data[GSOCK_MAX_EVENT];
98 int m_msgnumber;
99};
100
4b4d23c7
DE
101#ifdef __cplusplus
102extern "C" {
103#endif
104
904ec517
GRG
105/* Definition of GAddress */
106struct _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
904ec517
GRG
117
118/* GAddress */
119
120GSocketError _GAddress_translate_from(GAddress *address,
121 struct sockaddr *addr, int len);
d3ea6527
GRG
122GSocketError _GAddress_translate_to (GAddress *address,
123 struct sockaddr **addr, int *len);
904ec517
GRG
124GSocketError _GAddress_Init_INET(GAddress *address);
125GSocketError _GAddress_Init_UNIX(GAddress *address);
126
127#ifdef __cplusplus
128}
129#endif
130
0ce742cf
GRG
131#endif /* wxUSE_SOCKETS || defined(__GSOCKET_STANDALONE__) */
132
904ec517 133#endif /* __GSOCK_MSW_H */