1999-09-07 15:20:51 +00:00
|
|
|
/* -------------------------------------------------------------------------
|
2005-05-04 18:57:50 +00:00
|
|
|
* Project: GSocket (Generic Socket) for WX
|
|
|
|
* Name: gsockmsw.h
|
|
|
|
* Copyright: (c) Guilhem Lavaux
|
|
|
|
* Licence: wxWindows Licence
|
|
|
|
* Purpose: GSocket MSW header
|
|
|
|
* CVSID: $Id$
|
1999-09-07 15:20:51 +00:00
|
|
|
* -------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
|
2007-12-19 16:45:08 +00:00
|
|
|
#ifndef _WX_MSW_GSOCKMSW_H_
|
|
|
|
#define _WX_MSW_GSOCKMSW_H_
|
1999-09-07 15:20:51 +00:00
|
|
|
|
2004-08-03 03:33:36 +00:00
|
|
|
#include "wx/msw/wrapwin.h"
|
1999-09-15 00:02:49 +00:00
|
|
|
|
2005-04-10 06:33:26 +00:00
|
|
|
#if defined(__CYGWIN__)
|
|
|
|
//CYGWIN gives annoying warning about runtime stuff if we don't do this
|
|
|
|
# define USE_SYS_TYPES_FD_SET
|
|
|
|
# include <sys/types.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(__WXWINCE__) || defined(__CYGWIN__)
|
2005-02-10 14:55:27 +00:00
|
|
|
#include <winsock.h>
|
|
|
|
#endif
|
|
|
|
|
1999-09-07 15:20:51 +00:00
|
|
|
/* Definition of GSocket */
|
2008-11-23 00:11:09 +00:00
|
|
|
class GSocket : public GSocketBase
|
1999-09-07 15:20:51 +00:00
|
|
|
{
|
2004-08-03 03:33:36 +00:00
|
|
|
public:
|
2008-11-23 01:44:50 +00:00
|
|
|
GSocket() : GSocketBase() { m_msgnumber = 0; }
|
|
|
|
|
|
|
|
virtual void Close();
|
|
|
|
|
2004-08-03 03:33:36 +00:00
|
|
|
GSocketError SetLocal(GAddress *address);
|
|
|
|
GSocketError SetPeer(GAddress *address);
|
|
|
|
GAddress *GetLocal();
|
|
|
|
GAddress *GetPeer();
|
|
|
|
GSocketError SetServer();
|
|
|
|
GSocket *WaitConnection();
|
2007-12-19 16:45:08 +00:00
|
|
|
// not used under MSW
|
|
|
|
void Notify(bool) { }
|
2004-08-08 05:30:36 +00:00
|
|
|
bool SetReusable();
|
2007-07-04 21:33:11 +00:00
|
|
|
bool SetBroadcast();
|
|
|
|
bool DontDoBind();
|
2004-08-03 03:33:36 +00:00
|
|
|
GSocketError Connect(GSocketStream stream);
|
|
|
|
GSocketError SetNonOriented();
|
|
|
|
int Read(char *buffer, int size);
|
|
|
|
int Write(const char *buffer, int size);
|
|
|
|
void SetNonBlocking(bool non_block);
|
|
|
|
void SetTimeout(unsigned long millis);
|
2004-08-03 04:14:42 +00:00
|
|
|
GSocketError WXDLLIMPEXP_NET GetError();
|
2004-08-03 03:33:36 +00:00
|
|
|
void SetCallback(GSocketEventFlags flags,
|
|
|
|
GSocketCallback callback, char *cdata);
|
|
|
|
void UnsetCallback(GSocketEventFlags flags);
|
|
|
|
GSocketError GetSockOpt(int level, int optname,
|
|
|
|
void *optval, int *optlen);
|
|
|
|
GSocketError SetSockOpt(int level, int optname,
|
|
|
|
const void *optval, int optlen);
|
2007-11-17 15:21:26 +00:00
|
|
|
|
|
|
|
void SetInitialSocketBuffers(int recv, int send)
|
|
|
|
{
|
|
|
|
m_initialRecvBufferSize = recv;
|
|
|
|
m_initialSendBufferSize = send;
|
|
|
|
}
|
|
|
|
|
2004-08-03 03:33:36 +00:00
|
|
|
protected:
|
|
|
|
GSocketError Input_Timeout();
|
|
|
|
GSocketError Output_Timeout();
|
|
|
|
GSocketError Connect_Timeout();
|
|
|
|
int Recv_Stream(char *buffer, int size);
|
|
|
|
int Recv_Dgram(char *buffer, int size);
|
|
|
|
int Send_Stream(const char *buffer, int size);
|
|
|
|
int Send_Dgram(const char *buffer, int size);
|
|
|
|
|
|
|
|
/* TODO: Make these protected */
|
|
|
|
public:
|
1999-09-07 15:20:51 +00:00
|
|
|
|
|
|
|
int m_msgnumber;
|
|
|
|
};
|
|
|
|
|
2007-12-19 16:45:08 +00:00
|
|
|
#endif /* _WX_MSW_GSOCKMSW_H_ */
|