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 <libsoup/soup-types.h>
11 #define SOUP_TYPE_SOCKET (soup_socket_get_type ())
12 #define SOUP_SOCKET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SOUP_TYPE_SOCKET, SoupSocket))
13 #define SOUP_SOCKET_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SOUP_TYPE_SOCKET, SoupSocketClass))
14 #define SOUP_IS_SOCKET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SOUP_TYPE_SOCKET))
15 #define SOUP_IS_SOCKET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), SOUP_TYPE_SOCKET))
16 #define SOUP_SOCKET_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SOUP_TYPE_SOCKET, SoupSocketClass))
18 typedef struct SoupSocketPrivate SoupSocketPrivate;
23 SoupSocketPrivate *priv;
27 GObjectClass parent_class;
30 void (*connect_result) (SoupSocket *, guint);
31 void (*readable) (SoupSocket *);
32 void (*writable) (SoupSocket *);
33 void (*disconnected) (SoupSocket *);
35 void (*new_connection) (SoupSocket *, SoupSocket *);
38 #define SOUP_SOCKET_FLAG_NONBLOCKING "non-blocking"
39 #define SOUP_SOCKET_FLAG_NODELAY "nodelay"
40 #define SOUP_SOCKET_FLAG_REUSEADDR "reuseaddr"
41 #define SOUP_SOCKET_IS_SERVER "is-server"
42 #define SOUP_SOCKET_SSL_CREDENTIALS "ssl-creds"
44 GType soup_socket_get_type (void);
46 SoupSocket *soup_socket_new (const char *optname1,
49 guint soup_socket_connect (SoupSocket *sock,
50 SoupAddress *rem_addr);
51 gboolean soup_socket_listen (SoupSocket *sock,
52 SoupAddress *local_addr);
53 void soup_socket_start_ssl (SoupSocket *sock);
55 void soup_socket_disconnect (SoupSocket *sock);
56 gboolean soup_socket_is_connected (SoupSocket *sock);
58 typedef void (*SoupSocketCallback) (SoupSocket *sock,
61 typedef void (*SoupSocketListenerCallback) (SoupSocket *listener,
65 SoupSocket *soup_socket_client_new_async (const char *hostname,
68 SoupSocketCallback callback,
70 SoupSocket *soup_socket_client_new_sync (const char *hostname,
74 SoupSocket *soup_socket_server_new (SoupAddress *local_addr,
76 SoupSocketListenerCallback,
79 SoupAddress *soup_socket_get_local_address (SoupSocket *sock);
80 SoupAddress *soup_socket_get_remote_address (SoupSocket *sock);
85 SOUP_SOCKET_WOULD_BLOCK,
90 SoupSocketIOStatus soup_socket_read (SoupSocket *sock,
94 SoupSocketIOStatus soup_socket_read_until (SoupSocket *sock,
97 gconstpointer boundary,
100 gboolean *got_boundary);
102 SoupSocketIOStatus soup_socket_write (SoupSocket *sock,
103 gconstpointer buffer,
108 #endif /* SOUP_SOCKET_H */