Make this more like a struct sockaddr again (like it used to be). In
[platform/upstream/libsoup.git] / libsoup / soup-socket.h
1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2 /*
3  * Copyright (C) 2000-2003, Ximian, Inc.
4  */
5
6 #ifndef SOUP_SOCKET_H
7 #define SOUP_SOCKET_H 1
8
9 #include <glib-object.h>
10 #include <libsoup/soup-address.h>
11 #include <libsoup/soup-error.h>
12
13 #define SOUP_TYPE_SOCKET            (soup_socket_get_type ())
14 #define SOUP_SOCKET(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), SOUP_TYPE_SOCKET, SoupSocket))
15 #define SOUP_SOCKET_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), SOUP_TYPE_SOCKET, SoupSocketClass))
16 #define SOUP_IS_SOCKET(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SOUP_TYPE_SOCKET))
17 #define SOUP_IS_SOCKET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), SOUP_TYPE_SOCKET))
18 #define SOUP_SOCKET_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), SOUP_TYPE_SOCKET, SoupSocketClass))
19
20 typedef struct SoupSocketPrivate SoupSocketPrivate;
21
22 typedef struct {
23         GObject parent;
24
25         SoupSocketPrivate *priv;
26 } SoupSocket;
27
28 typedef struct {
29         GObjectClass parent_class;
30
31         /* signals */
32         void (*connect_result) (SoupSocket *, SoupKnownErrorCode);
33
34         void (*new_connection) (SoupSocket *, SoupSocket *);
35 } SoupSocketClass;
36
37 GType soup_socket_get_type (void);
38
39 SoupSocket    *soup_socket_new                (void);
40
41 void           soup_socket_connect            (SoupSocket         *sock,
42                                                SoupAddress        *rem_addr);
43 gboolean       soup_socket_listen             (SoupSocket         *sock,
44                                                SoupAddress        *local_addr);
45 void           soup_socket_start_ssl          (SoupSocket         *sock);
46
47
48 typedef void (*SoupSocketCallback)            (SoupSocket         *sock,
49                                                SoupKnownErrorCode  status,
50                                                gpointer            user_data);
51 typedef void (*SoupSocketListenerCallback)    (SoupSocket         *listener,
52                                                SoupSocket         *sock,
53                                                gpointer            user_data);
54
55 SoupSocket    *soup_socket_client_new         (const char         *hostname,
56                                                guint               port,
57                                                gboolean            ssl,
58                                                SoupSocketCallback  callback,
59                                                gpointer            user_data);
60 SoupSocket    *soup_socket_server_new         (SoupAddress        *local_addr,
61                                                gboolean            ssl,
62                                                SoupSocketListenerCallback,
63                                                gpointer            user_data);
64
65
66 GIOChannel    *soup_socket_get_iochannel      (SoupSocket         *sock);
67
68 SoupAddress   *soup_socket_get_local_address  (SoupSocket         *sock);
69 SoupAddress   *soup_socket_get_remote_address (SoupSocket         *sock);
70
71 #endif /* SOUP_SOCKET_H */