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();
66 void Notify(bool WXUNUSED(enable
)) { }
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
);
77 GSocketError WXDLLIMPEXP_NET
GetError();
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
);
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
);
95 /* TODO: Make these protected */
100 GSocketError m_error
;
110 struct timeval m_timeout
;
113 GSocketEventFlags m_detected
;
114 GSocketCallback m_cbacks
[GSOCK_MAX_EVENT
];
115 char *m_data
[GSOCK_MAX_EVENT
];
123 /* Definition of GAddress */
126 struct sockaddr
*m_addr
;
129 GAddressType m_family
;
132 GSocketError m_error
;
138 GSocketError
_GAddress_translate_from(GAddress
*address
,
139 struct sockaddr
*addr
, int len
);
140 GSocketError
_GAddress_translate_to (GAddress
*address
,
141 struct sockaddr
**addr
, int *len
);
142 GSocketError
_GAddress_Init_INET(GAddress
*address
);
143 GSocketError
_GAddress_Init_UNIX(GAddress
*address
);
149 #endif /* wxUSE_SOCKETS || defined(__GSOCKET_STANDALONE__) */
151 #endif /* __GSOCK_MSW_H */