1
/* GNet - Networking library
2
* Copyright (C) 2000 David Helder
3
* Copyright (C) 2000 Andrew Lanoix
5
* This library is free software; you can redistribute it and/or
6
* modify it under the terms of the GNU Library General Public
7
* License as published by the Free Software Foundation; either
8
* version 2 of the License, or (at your option) any later version.
10
* This library is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
* Library General Public License for more details.
15
* You should have received a copy of the GNU Library General Public
16
* License along with this library; if not, write to the
17
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18
* Boston, MA 02111-1307, USA.
31
#endif /* __cplusplus */
35
All fields in GTcpSocket are private and should be accessed only by
36
using the functions below.
39
typedef struct _GTcpSocket GTcpSocket;
42
/* **************************************** */
43
/* Asyncronous stuff */
47
* GTcpSocketConnectAsyncID:
49
* ID of an asynchronous connection started with
50
* gnet_tcp_socket_connect_async(). The connection can be canceled
51
* by calling gnet_tcp_socket_connect_async_cancel() with the ID.
54
typedef gpointer GTcpSocketConnectAsyncID;
59
* GTcpSocketConnectAsyncStatus:
61
* Status for connecting via gnet_tcp_socket_connect_async(), passed
62
* by GTcpSocketConnectAsyncFunc. More errors may be added in the
63
* future, so it's best to compare against
64
* %GTCP_SOCKET_CONNECT_ASYNC_STATUS_OK.
68
GTCP_SOCKET_CONNECT_ASYNC_STATUS_OK,
69
GTCP_SOCKET_CONNECT_ASYNC_STATUS_INETADDR_ERROR,
70
GTCP_SOCKET_CONNECT_ASYNC_STATUS_TCP_ERROR
71
} GTcpSocketConnectAsyncStatus;
76
* GTcpSocketConnectAsyncFunc:
77
* @socket: TcpSocket that was connecting
78
* @ia: InetAddr of the TcpSocket
79
* @status: Status of the connection
82
* Callback for gnet_tcp_socket_connect_async().
85
typedef void (*GTcpSocketConnectAsyncFunc)(GTcpSocket* socket,
87
GTcpSocketConnectAsyncStatus status,
92
* GTcpSocketNewAsyncID:
94
* ID of an asynchronous tcp socket creation started with
95
* gnet_tcp_socket_new_async(). The creation can be canceled by
96
* calling gnet_tcp_socket_new_async_cancel() with the ID.
99
typedef gpointer GTcpSocketNewAsyncID;
104
* GTcpSocketAsyncStatus:
106
* Status for connecting via gnet_tcp_socket_new_async(), passed by
107
* GTcpSocketNewAsyncFunc. More errors may be added in the future,
108
* so it's best to compare against %GTCP_SOCKET_NEW_ASYNC_STATUS_OK.
112
GTCP_SOCKET_NEW_ASYNC_STATUS_OK,
113
GTCP_SOCKET_NEW_ASYNC_STATUS_ERROR
114
} GTcpSocketNewAsyncStatus;
119
* GTcpSocketNewAsyncFunc:
120
* @socket: Socket that was connecting
121
* @status: Status of the connection
124
* Callback for gnet_tcp_socket_new_async().
127
typedef void (*GTcpSocketNewAsyncFunc)(GTcpSocket* socket,
128
GTcpSocketNewAsyncStatus status,
137
/* Quick and easy blocking constructor */
138
GTcpSocket* gnet_tcp_socket_connect (const gchar* hostname, gint port);
140
/* Quick and easy asynchronous constructor */
141
GTcpSocketConnectAsyncID
142
gnet_tcp_socket_connect_async (const gchar* hostname, gint port,
143
GTcpSocketConnectAsyncFunc func,
146
/* Cancel quick and easy asynchronous constructor */
147
void gnet_tcp_socket_connect_async_cancel (GTcpSocketConnectAsyncID id);
149
/* Blocking constructor */
150
GTcpSocket* gnet_tcp_socket_new (const GInetAddr* addr);
152
/* Asynchronous constructor */
154
gnet_tcp_socket_new_async (const GInetAddr* addr,
155
GTcpSocketNewAsyncFunc func,
158
/* Cancel asynchronous constructor */
159
void gnet_tcp_socket_new_async_cancel (GTcpSocketNewAsyncID id);
161
void gnet_tcp_socket_delete (GTcpSocket* s);
163
void gnet_tcp_socket_ref (GTcpSocket* s);
164
void gnet_tcp_socket_unref (GTcpSocket* s);
169
GIOChannel* gnet_tcp_socket_get_iochannel (GTcpSocket* socket);
170
GInetAddr* gnet_tcp_socket_get_inetaddr (const GTcpSocket* socket);
171
gint gnet_tcp_socket_get_port (const GTcpSocket* socket);
181
GNET_TOS_RELIABILITY,
186
void gnet_tcp_socket_set_tos (GTcpSocket* socket, GNetTOS tos);
191
GTcpSocket* gnet_tcp_socket_server_new (gint port);
192
GTcpSocket* gnet_tcp_socket_server_new_interface (const GInetAddr* iface);
194
GTcpSocket* gnet_tcp_socket_server_accept (const GTcpSocket* socket);
195
GTcpSocket* gnet_tcp_socket_server_accept_nonblock (const GTcpSocket* socket);
200
#endif /* __cplusplus */
202
#endif /* _GNET_TCP_H */