]> git.saurik.com Git - wxWidgets.git/blob - include/wx/msw/gsockmsw.h
don't duplicate GSocket creation/destruction and shutdown code in BSD and Winsock...
[wxWidgets.git] / include / wx / msw / gsockmsw.h
1 /* -------------------------------------------------------------------------
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$
8 * -------------------------------------------------------------------------
9 */
10
11 #ifndef _WX_MSW_GSOCKMSW_H_
12 #define _WX_MSW_GSOCKMSW_H_
13
14 #include "wx/msw/wrapwin.h"
15
16 #if defined(__CYGWIN__)
17 //CYGWIN gives annoying warning about runtime stuff if we don't do this
18 # define USE_SYS_TYPES_FD_SET
19 # include <sys/types.h>
20 #endif
21
22 #if defined(__WXWINCE__) || defined(__CYGWIN__)
23 #include <winsock.h>
24 #endif
25
26 /* Definition of GSocket */
27 class GSocket : public GSocketBase
28 {
29 public:
30 GSocket() : GSocketBase() { m_msgnumber = 0; }
31
32 virtual void Close();
33
34 GSocketError SetLocal(GAddress *address);
35 GSocketError SetPeer(GAddress *address);
36 GAddress *GetLocal();
37 GAddress *GetPeer();
38 GSocketError SetServer();
39 GSocket *WaitConnection();
40 // not used under MSW
41 void Notify(bool) { }
42 bool SetReusable();
43 bool SetBroadcast();
44 bool DontDoBind();
45 GSocketError Connect(GSocketStream stream);
46 GSocketError SetNonOriented();
47 int Read(char *buffer, int size);
48 int Write(const char *buffer, int size);
49 void SetNonBlocking(bool non_block);
50 void SetTimeout(unsigned long millis);
51 GSocketError WXDLLIMPEXP_NET GetError();
52 void SetCallback(GSocketEventFlags flags,
53 GSocketCallback callback, char *cdata);
54 void UnsetCallback(GSocketEventFlags flags);
55 GSocketError GetSockOpt(int level, int optname,
56 void *optval, int *optlen);
57 GSocketError SetSockOpt(int level, int optname,
58 const void *optval, int optlen);
59
60 void SetInitialSocketBuffers(int recv, int send)
61 {
62 m_initialRecvBufferSize = recv;
63 m_initialSendBufferSize = send;
64 }
65
66 protected:
67 GSocketError Input_Timeout();
68 GSocketError Output_Timeout();
69 GSocketError Connect_Timeout();
70 int Recv_Stream(char *buffer, int size);
71 int Recv_Dgram(char *buffer, int size);
72 int Send_Stream(const char *buffer, int size);
73 int Send_Dgram(const char *buffer, int size);
74
75 /* TODO: Make these protected */
76 public:
77
78 int m_msgnumber;
79 };
80
81 #endif /* _WX_MSW_GSOCKMSW_H_ */