1 /* -------------------------------------------------------------------------
2 * Project: GSocket (Generic Socket) for WX
4 * Copyright: (c) Guilhem Lavaux
5 * Licence: wxWindows Licence
6 * Purpose: GSocket MSW header
8 * -------------------------------------------------------------------------
14 #ifndef __GSOCKET_STANDALONE__
18 #if wxUSE_SOCKETS || defined(__GSOCKET_STANDALONE__)
20 #ifndef __GSOCKET_STANDALONE__
21 #include "wx/gsocket.h"
26 #include "wx/msw/wrapwin.h"
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>
34 #if defined(__WXWINCE__) || defined(__CYGWIN__)
38 class GSocketGUIFunctionsTableConcrete
: public GSocketGUIFunctionsTable
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
);
50 /* Definition of GSocket */
56 bool IsOk() { return m_ok
; }
59 GSocketError
SetLocal(GAddress
*address
);
60 GSocketError
SetPeer(GAddress
*address
);
63 GSocketError
SetServer();
64 GSocket
*WaitConnection();
68 GSocketError
Connect(GSocketStream stream
);
69 GSocketError
SetNonOriented();
70 int Read(char *buffer
, int size
);
71 int Write(const char *buffer
, int size
);
72 GSocketEventFlags
Select(GSocketEventFlags flags
);
73 void SetNonBlocking(bool non_block
);
74 void SetTimeout(unsigned long millis
);
75 GSocketError WXDLLIMPEXP_NET
GetError();
76 void SetCallback(GSocketEventFlags flags
,
77 GSocketCallback callback
, char *cdata
);
78 void UnsetCallback(GSocketEventFlags flags
);
79 GSocketError
GetSockOpt(int level
, int optname
,
80 void *optval
, int *optlen
);
81 GSocketError
SetSockOpt(int level
, int optname
,
82 const void *optval
, int optlen
);
84 void SetInitialSocketBuffers(int recv
, int send
)
86 m_initialRecvBufferSize
= recv
;
87 m_initialSendBufferSize
= send
;
91 GSocketError
Input_Timeout();
92 GSocketError
Output_Timeout();
93 GSocketError
Connect_Timeout();
94 int Recv_Stream(char *buffer
, int size
);
95 int Recv_Dgram(char *buffer
, int size
);
96 int Send_Stream(const char *buffer
, int size
);
97 int Send_Dgram(const char *buffer
, int size
);
99 int m_initialRecvBufferSize
;
100 int m_initialSendBufferSize
;
102 /* TODO: Make these protected */
107 GSocketError m_error
;
117 struct timeval m_timeout
;
120 GSocketEventFlags m_detected
;
121 GSocketCallback m_cbacks
[GSOCK_MAX_EVENT
];
122 char *m_data
[GSOCK_MAX_EVENT
];
130 /* Definition of GAddress */
133 struct sockaddr
*m_addr
;
136 GAddressType m_family
;
139 GSocketError m_error
;
145 GSocketError
_GAddress_translate_from(GAddress
*address
,
146 struct sockaddr
*addr
, int len
);
147 GSocketError
_GAddress_translate_to (GAddress
*address
,
148 struct sockaddr
**addr
, int *len
);
149 GSocketError
_GAddress_Init_INET(GAddress
*address
);
150 GSocketError
_GAddress_Init_UNIX(GAddress
*address
);
156 #endif /* wxUSE_SOCKETS || defined(__GSOCKET_STANDALONE__) */
158 #endif /* __GSOCK_MSW_H */