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 #include "wx/private/gsocketiohandler.h"
30 class GSocketGUIFunctionsTableConcrete
: public GSocketGUIFunctionsTable
33 virtual bool OnInit();
34 virtual void OnExit();
35 virtual bool CanUseEventLoop();
36 virtual bool Init_Socket(GSocket
*socket
);
37 virtual void Destroy_Socket(GSocket
*socket
);
38 virtual void Install_Callback(GSocket
*socket
, GSocketEvent event
);
39 virtual void Uninstall_Callback(GSocket
*socket
, GSocketEvent event
);
40 virtual void Enable_Events(GSocket
*socket
);
41 virtual void Disable_Events(GSocket
*socket
);
49 bool IsOk() { return m_ok
; }
52 GSocketError
SetLocal(GAddress
*address
);
53 GSocketError
SetPeer(GAddress
*address
);
56 GSocketError
SetServer();
57 GSocket
*WaitConnection();
61 GSocketError
Connect(GSocketStream stream
);
62 GSocketError
SetNonOriented();
63 int Read(char *buffer
, int size
);
64 int Write(const char *buffer
, int size
);
65 GSocketEventFlags
Select(GSocketEventFlags flags
);
66 void SetNonBlocking(bool non_block
);
67 void SetTimeout(unsigned long millisec
);
68 GSocketError WXDLLIMPEXP_NET
GetError();
69 void SetCallback(GSocketEventFlags flags
,
70 GSocketCallback callback
, char *cdata
);
71 void UnsetCallback(GSocketEventFlags flags
);
72 GSocketError
GetSockOpt(int level
, int optname
, void *optval
, int *optlen
);
73 GSocketError
SetSockOpt(int level
, int optname
,
74 const void *optval
, int optlen
);
75 // enable or disable notifications
76 void Notify(bool enable
);
77 virtual void Detected_Read();
78 virtual void Detected_Write();
80 //enable or disable event callback using gsocket gui callback table
81 void EnableEvents(bool flag
= true);
82 void DisableEvents() { EnableEvents(false); }
83 void Enable(GSocketEvent event
);
84 void Disable(GSocketEvent event
);
85 GSocketError
Input_Timeout();
86 GSocketError
Output_Timeout();
87 int Recv_Stream(char *buffer
, int size
);
88 int Recv_Dgram(char *buffer
, int size
);
89 int Send_Stream(const char *buffer
, int size
);
90 int Send_Dgram(const char *buffer
, int size
);
93 /* DFE: We can't protect these data member until the GUI code is updated */
96 wxGSocketIOHandler
*m_handler
;
108 unsigned long m_timeout
;
110 // true if socket should fire events (use GUI GSocketFunctionsTable)
114 GSocketEventFlags m_detected
;
115 GSocketCallback m_cbacks
[GSOCK_MAX_EVENT
];
116 char *m_data
[GSOCK_MAX_EVENT
];
118 char *m_gui_dependent
;
124 #endif /* __cplusplus */
125 /* Definition of GAddress */
128 struct sockaddr
*m_addr
;
131 GAddressType m_family
;
134 GSocketError m_error
;
138 #endif /* __cplusplus */
143 #endif /* __cplusplus */
148 GSocketError
_GAddress_translate_from(GAddress
*address
,
149 struct sockaddr
*addr
, int len
);
150 GSocketError
_GAddress_translate_to (GAddress
*address
,
151 struct sockaddr
**addr
, int *len
);
152 GSocketError
_GAddress_Init_INET(GAddress
*address
);
153 GSocketError
_GAddress_Init_UNIX(GAddress
*address
);
158 #endif /* __cplusplus */
160 #endif /* wxUSE_SOCKETS || defined(__GSOCKET_STANDALONE__) */
162 #endif /* __GSOCK_UNX_H */