1 /* -------------------------------------------------------------------------
2 * Project: GSocket (Generic Socket) for WX
4 * Copyright: (c) Guilhem Lavaux
5 * Licence: wxWindows Licence
6 * Purpose: GSocket Unix header
8 * -------------------------------------------------------------------------
14 #ifndef __GSOCKET_STANDALONE__
18 class wxGSocketIOHandler
;
20 #if wxUSE_SOCKETS || defined(__GSOCKET_STANDALONE__)
22 #ifndef __GSOCKET_STANDALONE__
23 #include "wx/gsocket.h"
28 class GSocketGUIFunctionsTableConcrete
: public GSocketGUIFunctionsTable
31 virtual bool OnInit();
32 virtual void OnExit();
33 virtual bool CanUseEventLoop();
34 virtual bool Init_Socket(GSocket
*socket
);
35 virtual void Destroy_Socket(GSocket
*socket
);
36 virtual void Install_Callback(GSocket
*socket
, GSocketEvent event
);
37 virtual void Uninstall_Callback(GSocket
*socket
, GSocketEvent event
);
38 virtual void Enable_Events(GSocket
*socket
);
39 virtual void Disable_Events(GSocket
*socket
);
47 bool IsOk() { return m_ok
; }
50 GSocketError
SetLocal(GAddress
*address
);
51 GSocketError
SetPeer(GAddress
*address
);
54 GSocketError
SetServer();
55 GSocket
*WaitConnection();
59 GSocketError
Connect(GSocketStream stream
);
60 GSocketError
SetNonOriented();
61 int Read(char *buffer
, int size
);
62 int Write(const char *buffer
, int size
);
63 GSocketEventFlags
Select(GSocketEventFlags flags
);
64 void SetNonBlocking(bool non_block
);
65 void SetTimeout(unsigned long millisec
);
66 GSocketError WXDLLIMPEXP_NET
GetError();
67 void SetCallback(GSocketEventFlags flags
,
68 GSocketCallback callback
, char *cdata
);
69 void UnsetCallback(GSocketEventFlags flags
);
70 GSocketError
GetSockOpt(int level
, int optname
, void *optval
, int *optlen
);
71 GSocketError
SetSockOpt(int level
, int optname
,
72 const void *optval
, int optlen
);
73 virtual void Detected_Read();
74 virtual void Detected_Write();
75 void SetInitialSocketBuffers(int recv
, int send
)
77 m_initialRecvBufferSize
= recv
;
78 m_initialSendBufferSize
= send
;
82 void Enable(GSocketEvent event
);
83 void Disable(GSocketEvent event
);
84 GSocketError
Input_Timeout();
85 GSocketError
Output_Timeout();
86 int Recv_Stream(char *buffer
, int size
);
87 int Recv_Dgram(char *buffer
, int size
);
88 int Send_Stream(const char *buffer
, int size
);
89 int Send_Dgram(const char *buffer
, int size
);
91 int m_initialRecvBufferSize
;
92 int m_initialSendBufferSize
;
94 /* DFE: We can't protect these data member until the GUI code is updated */
97 wxGSocketIOHandler
*m_handler
;
100 GSocketError m_error
;
109 unsigned long m_timeout
;
112 GSocketEventFlags m_detected
;
113 GSocketCallback m_cbacks
[GSOCK_MAX_EVENT
];
114 char *m_data
[GSOCK_MAX_EVENT
];
116 char *m_gui_dependent
;
122 #endif /* __cplusplus */
123 /* Definition of GAddress */
126 struct sockaddr
*m_addr
;
129 GAddressType m_family
;
132 GSocketError m_error
;
136 #endif /* __cplusplus */
141 #endif /* __cplusplus */
146 GSocketError
_GAddress_translate_from(GAddress
*address
,
147 struct sockaddr
*addr
, int len
);
148 GSocketError
_GAddress_translate_to (GAddress
*address
,
149 struct sockaddr
**addr
, int *len
);
150 GSocketError
_GAddress_Init_INET(GAddress
*address
);
151 GSocketError
_GAddress_Init_UNIX(GAddress
*address
);
156 #endif /* __cplusplus */
158 #endif /* wxUSE_SOCKETS || defined(__GSOCKET_STANDALONE__) */
160 #endif /* __GSOCK_UNX_H */