1 /* -------------------------------------------------------------------------
2 * Project: GSocket (Generic Socket) for WX
4 * Purpose: GSocket MSW header
6 * -------------------------------------------------------------------------
12 #ifndef __GSOCKET_STANDALONE__
16 #if wxUSE_SOCKETS || defined(__GSOCKET_STANDALONE__)
18 #ifndef __GSOCKET_STANDALONE__
19 #include "wx/gsocket.h"
24 #include "wx/msw/wrapwin.h"
26 #if defined(__CYGWIN__)
27 //CYGWIN gives annoying warning about runtime stuff if we don't do this
28 # define USE_SYS_TYPES_FD_SET
29 # include <sys/types.h>
32 #if defined(__WXWINCE__) || defined(__CYGWIN__)
36 class GSocketGUIFunctionsTableConcrete
: public GSocketGUIFunctionsTable
39 virtual bool OnInit();
40 virtual void OnExit();
41 virtual bool CanUseEventLoop();
42 virtual bool Init_Socket(GSocket
*socket
);
43 virtual void Destroy_Socket(GSocket
*socket
);
44 virtual void Enable_Events(GSocket
*socket
);
45 virtual void Disable_Events(GSocket
*socket
);
48 /* Definition of GSocket */
54 bool IsOk() { return m_ok
; }
57 GSocketError
SetLocal(GAddress
*address
);
58 GSocketError
SetPeer(GAddress
*address
);
61 GSocketError
SetServer();
62 GSocket
*WaitConnection();
64 GSocketError
Connect(GSocketStream stream
);
65 GSocketError
SetNonOriented();
66 int Read(char *buffer
, int size
);
67 int Write(const char *buffer
, int size
);
68 GSocketEventFlags
Select(GSocketEventFlags flags
);
69 void SetNonBlocking(bool non_block
);
70 void SetTimeout(unsigned long millis
);
71 GSocketError WXDLLIMPEXP_NET
GetError();
72 void SetCallback(GSocketEventFlags flags
,
73 GSocketCallback callback
, char *cdata
);
74 void UnsetCallback(GSocketEventFlags flags
);
75 GSocketError
GetSockOpt(int level
, int optname
,
76 void *optval
, int *optlen
);
77 GSocketError
SetSockOpt(int level
, int optname
,
78 const void *optval
, int optlen
);
80 GSocketError
Input_Timeout();
81 GSocketError
Output_Timeout();
82 GSocketError
Connect_Timeout();
83 int Recv_Stream(char *buffer
, int size
);
84 int Recv_Dgram(char *buffer
, int size
);
85 int Send_Stream(const char *buffer
, int size
);
86 int Send_Dgram(const char *buffer
, int size
);
89 /* TODO: Make these protected */
102 struct timeval m_timeout
;
105 GSocketEventFlags m_detected
;
106 GSocketCallback m_cbacks
[GSOCK_MAX_EVENT
];
107 char *m_data
[GSOCK_MAX_EVENT
];
115 /* Definition of GAddress */
118 struct sockaddr
*m_addr
;
121 GAddressType m_family
;
124 GSocketError m_error
;
130 GSocketError
_GAddress_translate_from(GAddress
*address
,
131 struct sockaddr
*addr
, int len
);
132 GSocketError
_GAddress_translate_to (GAddress
*address
,
133 struct sockaddr
**addr
, int *len
);
134 GSocketError
_GAddress_Init_INET(GAddress
*address
);
135 GSocketError
_GAddress_Init_UNIX(GAddress
*address
);
141 #endif /* wxUSE_SOCKETS || defined(__GSOCKET_STANDALONE__) */
143 #endif /* __GSOCK_MSW_H */