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))
24 GObjectClass parent_class;
27 void (*connect_result) (SoupSocket *, guint);
28 void (*readable) (SoupSocket *);
29 void (*writable) (SoupSocket *);
30 void (*disconnected) (SoupSocket *);
32 void (*new_connection) (SoupSocket *, SoupSocket *);
35 #define SOUP_SOCKET_FLAG_NONBLOCKING "non-blocking"
36 #define SOUP_SOCKET_FLAG_NODELAY "nodelay"
37 #define SOUP_SOCKET_FLAG_REUSEADDR "reuseaddr"
38 #define SOUP_SOCKET_FLAG_CLOEXEC "cloexec"
39 #define SOUP_SOCKET_IS_SERVER "is-server"
40 #define SOUP_SOCKET_SSL_CREDENTIALS "ssl-creds"
44 * @sock: the #SoupSocket
45 * @status: an HTTP status code indicating success or failure
46 * @user_data: the data passed to soup_socket_client_new_async()
48 * The callback function passed to soup_socket_client_new_async().
50 typedef void (*SoupSocketCallback) (SoupSocket *sock,
55 * SoupSocketListenerCallback:
56 * @listener: the listening #SoupSocket
57 * @sock: the newly-received #SoupSocket
58 * @user_data: the data passed to soup_socket_server_new().
60 * The callback function passed to soup_socket_server_new(), which
61 * receives new connections.
63 typedef void (*SoupSocketListenerCallback) (SoupSocket *listener,
67 GType soup_socket_get_type (void);
69 SoupSocket *soup_socket_new (const char *optname1,
72 guint soup_socket_connect (SoupSocket *sock,
73 SoupAddress *remote_addr);
74 gboolean soup_socket_listen (SoupSocket *sock,
75 SoupAddress *local_addr);
76 gboolean soup_socket_start_ssl (SoupSocket *sock);
77 gboolean soup_socket_start_proxy_ssl (SoupSocket *sock,
78 const char *ssl_host);
80 void soup_socket_disconnect (SoupSocket *sock);
81 gboolean soup_socket_is_connected (SoupSocket *sock);
83 SoupSocket *soup_socket_client_new_async (const char *hostname,
86 SoupSocketCallback callback,
88 SoupSocket *soup_socket_client_new_sync (const char *hostname,
92 SoupSocket *soup_socket_server_new (SoupAddress *local_addr,
94 SoupSocketListenerCallback callback,
97 SoupAddress *soup_socket_get_local_address (SoupSocket *sock);
98 SoupAddress *soup_socket_get_remote_address (SoupSocket *sock);
102 * SoupSocketIOStatus:
103 * @SOUP_SOCKET_OK: Success
104 * @SOUP_SOCKET_WOULD_BLOCK: Cannot read/write any more at this time
105 * @SOUP_SOCKET_EOF: End of file
106 * @SOUP_SOCKET_ERROR: Other error
108 * Return value from the #SoupSocket IO methods.
112 SOUP_SOCKET_WOULD_BLOCK,
115 } SoupSocketIOStatus;
117 SoupSocketIOStatus soup_socket_read (SoupSocket *sock,
121 SoupSocketIOStatus soup_socket_read_until (SoupSocket *sock,
124 gconstpointer boundary,
127 gboolean *got_boundary);
129 SoupSocketIOStatus soup_socket_write (SoupSocket *sock,
130 gconstpointer buffer,
135 #endif /* SOUP_SOCKET_H */