1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
3 * soup-socket.c: ronous Callback-based SOAP Request Queue.
6 * David Helder (dhelder@umich.edu)
7 * Alex Graveley (alex@helixcode.com)
9 * Original code compliments of David Helder's GNET Networking Library.
11 * Copyright (C) 2000, Helix Code, Inc.
15 #define SOUP_SOCKET_H 1
18 #include <sys/socket.h>
20 gboolean soup_gethostbyname (const gchar *hostname,
21 struct sockaddr_in *sa,
24 gchar *soup_gethostbyaddr (const gchar *addr,
28 typedef struct _SoupAddress SoupAddress;
30 typedef gpointer SoupAddressNewId;
33 SOUP_ADDRESS_STATUS_OK,
34 SOUP_ADDRESS_STATUS_ERROR
37 typedef void (*SoupAddressNewFn) (SoupAddress *inetaddr,
38 SoupAddressStatus status,
41 SoupAddressNewId soup_address_new (const gchar* name,
43 SoupAddressNewFn func,
46 void soup_address_new_cancel (SoupAddressNewId id);
48 SoupAddress *soup_address_new_sync (const gchar *name,
51 void soup_address_ref (SoupAddress* ia);
53 void soup_address_unref (SoupAddress* ia);
55 SoupAddress * soup_address_copy (SoupAddress* ia);
58 typedef gpointer SoupAddressGetNameId;
60 typedef void (*SoupAddressGetNameFn) (SoupAddress *inetaddr,
61 SoupAddressStatus status,
65 SoupAddressGetNameId soup_address_get_name (SoupAddress* ia,
66 SoupAddressGetNameFn func,
69 void soup_address_get_name_cancel (SoupAddressGetNameId id);
71 const gchar *soup_address_get_name_sync (SoupAddress *addr);
73 gchar* soup_address_get_canonical_name (SoupAddress* ia);
75 gint soup_address_get_port (const SoupAddress* ia);
77 void soup_address_set_port (const SoupAddress* ia,
80 guint soup_address_hash (const gpointer p);
82 gint soup_address_equal (const gpointer p1,
85 gint soup_address_noport_equal (const gpointer p1,
88 gchar* soup_address_gethostname (void);
90 SoupAddress* soup_address_gethostaddr (void);
93 typedef struct _SoupSocket SoupSocket;
95 typedef gpointer SoupSocketConnectId;
98 SOUP_SOCKET_CONNECT_ERROR_NONE,
99 SOUP_SOCKET_CONNECT_ERROR_ADDR_RESOLVE,
100 SOUP_SOCKET_CONNECT_ERROR_NETWORK
101 } SoupSocketConnectStatus;
103 typedef void (*SoupSocketConnectFn) (SoupSocket *socket,
104 SoupSocketConnectStatus status,
107 SoupSocketConnectId soup_socket_connect (const gchar* hostname,
109 SoupSocketConnectFn func,
112 void soup_socket_connect_cancel (SoupSocketConnectId id);
114 SoupSocket *soup_socket_connect_sync (const gchar *hostname,
119 typedef gpointer SoupSocketNewId;
122 SOUP_SOCKET_NEW_STATUS_OK,
123 SOUP_SOCKET_NEW_STATUS_ERROR
124 } SoupSocketNewStatus;
126 typedef void (*SoupSocketNewFn) (SoupSocket* socket,
127 SoupSocketNewStatus status,
130 SoupSocketNewId soup_socket_new (SoupAddress *addr,
131 SoupSocketNewFn func,
134 void soup_socket_new_cancel (SoupSocketNewId id);
136 SoupSocket *soup_socket_new_sync (SoupAddress *addr);
139 void soup_socket_ref (SoupSocket* s);
141 void soup_socket_unref (SoupSocket* s);
143 GIOChannel *soup_socket_get_iochannel (SoupSocket* socket);
145 SoupAddress *soup_socket_get_address (const SoupSocket* socket);
147 gint soup_socket_get_port (const SoupSocket* socket);
150 #define SOUP_SERVER_ANY_PORT 0
152 SoupSocket *soup_socket_server_new (const gint port);
154 SoupSocket *soup_socket_server_accept (SoupSocket *socket);
156 SoupSocket *soup_socket_server_try_accept (SoupSocket *socket);
158 #endif /* SOUP_SOCKET_H */