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"
41 #define SOUP_SOCKET_ASYNC_CONTEXT "async-context"
45 * @sock: the #SoupSocket
46 * @status: an HTTP status code indicating success or failure
47 * @user_data: the data passed to soup_socket_client_new_async()
49 * The callback function passed to soup_socket_client_new_async().
51 typedef void (*SoupSocketCallback) (SoupSocket *sock,
56 * SoupSocketListenerCallback:
57 * @listener: the listening #SoupSocket
58 * @sock: the newly-received #SoupSocket
59 * @user_data: the data passed to soup_socket_server_new().
61 * The callback function passed to soup_socket_server_new(), which
62 * receives new connections.
64 typedef void (*SoupSocketListenerCallback) (SoupSocket *listener,
68 GType soup_socket_get_type (void);
70 SoupSocket *soup_socket_new (const char *optname1,
71 ...) G_GNUC_NULL_TERMINATED;
73 guint soup_socket_connect (SoupSocket *sock,
74 SoupAddress *remote_addr);
75 gboolean soup_socket_listen (SoupSocket *sock,
76 SoupAddress *local_addr);
77 gboolean soup_socket_start_ssl (SoupSocket *sock);
78 gboolean soup_socket_start_proxy_ssl (SoupSocket *sock,
79 const char *ssl_host);
81 void soup_socket_disconnect (SoupSocket *sock);
82 gboolean soup_socket_is_connected (SoupSocket *sock);
84 SoupSocket *soup_socket_client_new_async (const char *hostname,
87 SoupSocketCallback callback,
89 SoupSocket *soup_socket_client_new_sync (const char *hostname,
93 SoupSocket *soup_socket_server_new (SoupAddress *local_addr,
95 SoupSocketListenerCallback callback,
98 SoupAddress *soup_socket_get_local_address (SoupSocket *sock);
99 SoupAddress *soup_socket_get_remote_address (SoupSocket *sock);
103 * SoupSocketIOStatus:
104 * @SOUP_SOCKET_OK: Success
105 * @SOUP_SOCKET_WOULD_BLOCK: Cannot read/write any more at this time
106 * @SOUP_SOCKET_EOF: End of file
107 * @SOUP_SOCKET_ERROR: Other error
109 * Return value from the #SoupSocket IO methods.
113 SOUP_SOCKET_WOULD_BLOCK,
116 } SoupSocketIOStatus;
118 SoupSocketIOStatus soup_socket_read (SoupSocket *sock,
122 SoupSocketIOStatus soup_socket_read_until (SoupSocket *sock,
125 gconstpointer boundary,
128 gboolean *got_boundary);
130 SoupSocketIOStatus soup_socket_write (SoupSocket *sock,
131 gconstpointer buffer,
136 #endif /* SOUP_SOCKET_H */