Change old Helix Code refs to Ximian (and update copyright dates).
[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@ximian.com)
8  * 
9  * Original code compliments of David Helder's GNET Networking Library.
10  *
11  * Copyright (C) 2000-2002, Ximian, 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                                                  guint               port,
58                                                  SoupSocketNewFn     func,
59                                                  gpointer            data);
60
61 void                soup_socket_new_cancel      (SoupSocketNewId     id);
62
63 SoupSocket         *soup_socket_new_sync        (SoupAddress        *addr,
64                                                  guint               port);
65
66
67 void                soup_socket_ref             (SoupSocket*         s);
68
69 void                soup_socket_unref           (SoupSocket*         s);
70
71 GIOChannel         *soup_socket_get_iochannel   (SoupSocket*         socket);
72
73 SoupAddress        *soup_socket_get_address     (const SoupSocket*   socket);
74
75 gint                soup_socket_get_port        (const SoupSocket*   socket);
76
77
78 #define SOUP_SERVER_ANY_PORT 0
79
80 SoupSocket         *soup_socket_server_new        (SoupAddress        *local_addr,
81                                                    guint               local_port);
82
83 SoupSocket         *soup_socket_server_accept     (SoupSocket         *socket);
84
85 SoupSocket         *soup_socket_server_try_accept (SoupSocket         *socket);
86
87 #endif /* SOUP_SOCKET_H */