1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
3 * Copyright (C) 2000-2003, Ximian, Inc.
7 #define SOUP_SOCKET_H 1
9 #include <glib-object.h>
10 #include <libsoup/soup-address.h>
12 #define SOUP_TYPE_SOCKET (soup_socket_get_type ())
13 #define SOUP_SOCKET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SOUP_TYPE_SOCKET, SoupSocket))
14 #define SOUP_SOCKET_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SOUP_TYPE_SOCKET, SoupSocketClass))
15 #define SOUP_IS_SOCKET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SOUP_TYPE_SOCKET))
16 #define SOUP_IS_SOCKET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), SOUP_TYPE_SOCKET))
17 #define SOUP_SOCKET_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SOUP_TYPE_SOCKET, SoupSocketClass))
19 typedef struct SoupSocketPrivate SoupSocketPrivate;
24 SoupSocketPrivate *priv;
28 GObjectClass parent_class;
32 GType soup_socket_get_type (void);
35 typedef gpointer SoupSocketConnectId;
38 SOUP_SOCKET_CONNECT_ERROR_NONE,
39 SOUP_SOCKET_CONNECT_ERROR_ADDR_RESOLVE,
40 SOUP_SOCKET_CONNECT_ERROR_NETWORK
41 } SoupSocketConnectStatus;
43 typedef void (*SoupSocketConnectFn) (SoupSocket *socket,
44 SoupSocketConnectStatus status,
47 SoupSocketConnectId soup_socket_connect (const char *hostname,
49 SoupSocketConnectFn func,
52 void soup_socket_connect_cancel (SoupSocketConnectId id);
54 SoupSocket *soup_socket_connect_sync (const char *hostname,
58 typedef gpointer SoupSocketNewId;
61 SOUP_SOCKET_NEW_STATUS_OK,
62 SOUP_SOCKET_NEW_STATUS_ERROR
63 } SoupSocketNewStatus;
65 typedef void (*SoupSocketNewFn) (SoupSocket* socket,
66 SoupSocketNewStatus status,
69 SoupSocketNewId soup_socket_new (SoupAddress *addr,
74 void soup_socket_new_cancel (SoupSocketNewId id);
76 SoupSocket *soup_socket_new_sync (SoupAddress *addr,
80 GIOChannel *soup_socket_get_iochannel (SoupSocket* socket);
82 SoupAddress *soup_socket_get_address (const SoupSocket* socket);
84 guint soup_socket_get_port (const SoupSocket* socket);
87 #define SOUP_SERVER_ANY_PORT 0
89 SoupSocket *soup_socket_server_new (SoupAddress *local_addr,
92 SoupSocket *soup_socket_server_accept (SoupSocket *socket);
94 SoupSocket *soup_socket_server_try_accept (SoupSocket *socket);
96 #endif /* SOUP_SOCKET_H */