Move the SoupAddress code from soup-socket.c and soup-socket-unix.c to
[platform/upstream/libsoup.git] / libsoup / soup-socket.h
1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2 /*
3  * soup-socket.c: ronous Callback-based HTTP Request Queue.
4  *
5  * Authors:
6  *      David Helder  (dhelder@umich.edu)
7  *      Alex Graveley (alex@helixcode.com)
8  * 
9  * Original code compliments of David Helder's GNET Networking Library.
10  *
11  * Copyright (C) 2000, Helix Code, Inc.
12  */
13
14 #ifndef SOUP_SOCKET_H
15 #define SOUP_SOCKET_H 1
16
17 #include <glib.h>
18 #include <libsoup/soup-address.h>
19
20 typedef struct _SoupSocket SoupSocket;
21
22 typedef gpointer SoupSocketConnectId;
23
24 typedef enum {
25         SOUP_SOCKET_CONNECT_ERROR_NONE,
26         SOUP_SOCKET_CONNECT_ERROR_ADDR_RESOLVE,
27         SOUP_SOCKET_CONNECT_ERROR_NETWORK
28 } SoupSocketConnectStatus;
29
30 typedef void (*SoupSocketConnectFn) (SoupSocket              *socket, 
31                                      SoupSocketConnectStatus  status, 
32                                      gpointer                 data);
33
34 SoupSocketConnectId  soup_socket_connect        (const gchar*        hostname,
35                                                  const gint          port, 
36                                                  SoupSocketConnectFn func, 
37                                                  gpointer            data);
38
39 void                 soup_socket_connect_cancel (SoupSocketConnectId id);
40
41 SoupSocket          *soup_socket_connect_sync   (const gchar        *hostname, 
42                                                  const gint          port);
43
44
45 typedef gpointer SoupSocketNewId;
46
47 typedef enum {
48         SOUP_SOCKET_NEW_STATUS_OK,
49         SOUP_SOCKET_NEW_STATUS_ERROR
50 } SoupSocketNewStatus;
51
52 typedef void (*SoupSocketNewFn) (SoupSocket*         socket, 
53                                  SoupSocketNewStatus status, 
54                                  gpointer            data);
55
56 SoupSocketNewId     soup_socket_new             (SoupAddress        *addr, 
57                                                  SoupSocketNewFn     func,
58                                                  gpointer            data);
59
60 void                soup_socket_new_cancel      (SoupSocketNewId     id);
61
62 SoupSocket         *soup_socket_new_sync        (SoupAddress        *addr);
63
64
65 void                soup_socket_ref             (SoupSocket*         s);
66
67 void                soup_socket_unref           (SoupSocket*         s);
68
69 GIOChannel         *soup_socket_get_iochannel   (SoupSocket*         socket);
70
71 SoupAddress        *soup_socket_get_address     (const SoupSocket*   socket);
72
73 gint                soup_socket_get_port        (const SoupSocket*   socket);
74
75
76 #define SOUP_SERVER_ANY_PORT 0
77
78 SoupSocket         *soup_socket_server_new        (const gint          port);
79
80 SoupSocket         *soup_socket_server_accept     (SoupSocket         *socket);
81
82 SoupSocket         *soup_socket_server_try_accept (SoupSocket         *socket);
83
84 #endif /* SOUP_SOCKET_H */