1 /* -------------------------------------------------------------------------
2 * Project: GSocket (Generic Socket) for WX
4 * Purpose: GSocket Unix header
6 * -------------------------------------------------------------------------
12 #ifndef __GSOCKET_STANDALONE__
16 #if wxUSE_SOCKETS || defined(__GSOCKET_STANDALONE__)
18 #ifndef __GSOCKET_STANDALONE__
19 #include "wx/gsocket.h"
24 class GSocketGUIFunctionsTableConcrete
: public GSocketGUIFunctionsTable
27 virtual bool OnInit();
28 virtual void OnExit();
29 virtual bool CanUseEventLoop();
30 virtual bool Init_Socket(GSocket
*socket
);
31 virtual void Destroy_Socket(GSocket
*socket
);
32 virtual void Install_Callback(GSocket
*socket
, GSocketEvent event
);
33 virtual void Uninstall_Callback(GSocket
*socket
, GSocketEvent event
);
34 virtual void Enable_Events(GSocket
*socket
);
35 virtual void Disable_Events(GSocket
*socket
);
43 bool IsOk() { return m_ok
; }
46 GSocketError
SetLocal(GAddress
*address
);
47 GSocketError
SetPeer(GAddress
*address
);
50 GSocketError
SetServer();
51 GSocket
*WaitConnection();
53 GSocketError
Connect(GSocketStream stream
);
54 GSocketError
SetNonOriented();
55 int Read(char *buffer
, int size
);
56 int Write(const char *buffer
, int size
);
57 GSocketEventFlags
Select(GSocketEventFlags flags
);
58 void SetNonBlocking(bool non_block
);
59 void SetTimeout(unsigned long millisec
);
60 GSocketError WXDLLIMPEXP_NET
GetError();
61 void SetCallback(GSocketEventFlags flags
,
62 GSocketCallback callback
, char *cdata
);
63 void UnsetCallback(GSocketEventFlags flags
);
64 GSocketError
GetSockOpt(int level
, int optname
, void *optval
, int *optlen
);
65 GSocketError
SetSockOpt(int level
, int optname
,
66 const void *optval
, int optlen
);
67 /* API compatibility functions */
68 static void _GSocket_Detected_Read(GSocket
*socket
);
69 static void _GSocket_Detected_Write(GSocket
*socket
);
70 virtual void Detected_Read();
71 virtual void Detected_Write();
73 void Enable(GSocketEvent event
);
74 void Disable(GSocketEvent event
);
75 GSocketError
Input_Timeout();
76 GSocketError
Output_Timeout();
77 int Recv_Stream(char *buffer
, int size
);
78 int Recv_Dgram(char *buffer
, int size
);
79 int Send_Stream(const char *buffer
, int size
);
80 int Send_Dgram(const char *buffer
, int size
);
83 /* DFE: We can't protect these data member until the GUI code is updated */
95 unsigned long m_timeout
;
98 GSocketEventFlags m_detected
;
99 GSocketCallback m_cbacks
[GSOCK_MAX_EVENT
];
100 char *m_data
[GSOCK_MAX_EVENT
];
102 char *m_gui_dependent
;
108 #endif /* __cplusplus */
109 /* Definition of GAddress */
112 struct sockaddr
*m_addr
;
115 GAddressType m_family
;
118 GSocketError m_error
;
122 #endif /* __cplusplus */
127 #endif /* __cplusplus */
132 GSocketError
_GAddress_translate_from(GAddress
*address
,
133 struct sockaddr
*addr
, int len
);
134 GSocketError
_GAddress_translate_to (GAddress
*address
,
135 struct sockaddr
**addr
, int *len
);
136 GSocketError
_GAddress_Init_INET(GAddress
*address
);
137 GSocketError
_GAddress_Init_UNIX(GAddress
*address
);
142 #endif /* __cplusplus */
144 #endif /* wxUSE_SOCKETS || defined(__GSOCKET_STANDALONE__) */
146 #endif /* __GSOCK_UNX_H */