Add soup-socket-win.c.
[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 SOAP 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 <sys/socket.h>
19
20 gboolean  soup_gethostbyname (const gchar         *hostname,
21                               struct sockaddr_in  *sa,
22                               gchar              **nicename);
23
24 gchar    *soup_gethostbyaddr (const gchar         *addr, 
25                               size_t               length, 
26                               int                  type);
27
28 typedef struct _SoupAddress SoupAddress;
29
30 typedef gpointer SoupAddressNewId;
31
32 typedef enum {
33         SOUP_ADDRESS_STATUS_OK,
34         SOUP_ADDRESS_STATUS_ERROR
35 } SoupAddressStatus;
36
37 typedef void (*SoupAddressNewFn) (SoupAddress       *inetaddr, 
38                                   SoupAddressStatus  status, 
39                                   gpointer           user_data);
40
41 SoupAddressNewId     soup_address_new                (const gchar*       name, 
42                                                       const gint         port, 
43                                                       SoupAddressNewFn   func, 
44                                                       gpointer           data);
45
46 void                 soup_address_new_cancel         (SoupAddressNewId   id);
47
48 SoupAddress         *soup_address_new_sync           (const gchar *name, 
49                                                       const gint port);
50
51 void                 soup_address_ref                (SoupAddress*       ia);
52
53 void                 soup_address_unref              (SoupAddress*       ia);
54
55 SoupAddress *        soup_address_copy               (SoupAddress*       ia);
56
57
58 typedef gpointer SoupAddressGetNameId;
59
60 typedef void (*SoupAddressGetNameFn) (SoupAddress       *inetaddr, 
61                                       SoupAddressStatus  status, 
62                                       const gchar       *name,
63                                       gpointer           user_data);
64
65 SoupAddressGetNameId soup_address_get_name           (SoupAddress*         ia, 
66                                                       SoupAddressGetNameFn func,
67                                                       gpointer             data);
68
69 void                 soup_address_get_name_cancel    (SoupAddressGetNameId id);
70
71 const gchar         *soup_address_get_name_sync      (SoupAddress *addr);
72
73 gchar*               soup_address_get_canonical_name (SoupAddress*         ia);
74
75 gint                 soup_address_get_port           (const SoupAddress*   ia);
76
77 void                 soup_address_set_port           (const SoupAddress*   ia, 
78                                                       guint                port);
79
80 guint                soup_address_hash               (const gpointer       p);
81
82 gint                 soup_address_equal              (const gpointer       p1, 
83                                                       const gpointer       p2);
84
85 gint                 soup_address_noport_equal       (const gpointer       p1, 
86                                                       const gpointer       p2);
87
88 gchar*               soup_address_gethostname        (void);
89
90 SoupAddress*         soup_address_gethostaddr        (void);
91
92
93 typedef struct _SoupSocket SoupSocket;
94
95 typedef gpointer SoupSocketConnectId;
96
97 typedef enum {
98         SOUP_SOCKET_CONNECT_ERROR_NONE,
99         SOUP_SOCKET_CONNECT_ERROR_ADDR_RESOLVE,
100         SOUP_SOCKET_CONNECT_ERROR_NETWORK
101 } SoupSocketConnectStatus;
102
103 typedef void (*SoupSocketConnectFn) (SoupSocket              *socket, 
104                                      SoupSocketConnectStatus  status, 
105                                      gpointer                 data);
106
107 SoupSocketConnectId  soup_socket_connect        (const gchar*        hostname,
108                                                  const gint          port, 
109                                                  SoupSocketConnectFn func, 
110                                                  gpointer            data);
111
112 void                 soup_socket_connect_cancel (SoupSocketConnectId id);
113
114 SoupSocket          *soup_socket_connect_sync   (const gchar        *hostname, 
115                                                  const gint          port);
116
117
118
119 typedef gpointer SoupSocketNewId;
120
121 typedef enum {
122         SOUP_SOCKET_NEW_STATUS_OK,
123         SOUP_SOCKET_NEW_STATUS_ERROR
124 } SoupSocketNewStatus;
125
126 typedef void (*SoupSocketNewFn) (SoupSocket*         socket, 
127                                  SoupSocketNewStatus status, 
128                                  gpointer            data);
129
130 SoupSocketNewId     soup_socket_new             (SoupAddress        *addr, 
131                                                  SoupSocketNewFn     func,
132                                                  gpointer            data);
133
134 void                soup_socket_new_cancel      (SoupSocketNewId     id);
135
136 SoupSocket         *soup_socket_new_sync        (SoupAddress        *addr);
137
138
139 void                soup_socket_ref             (SoupSocket*         s);
140
141 void                soup_socket_unref           (SoupSocket*         s);
142
143 GIOChannel         *soup_socket_get_iochannel   (SoupSocket*         socket);
144
145 SoupAddress        *soup_socket_get_address     (const SoupSocket*   socket);
146
147 gint                soup_socket_get_port        (const SoupSocket*   socket);
148
149
150 #define SOUP_SERVER_ANY_PORT 0
151
152 SoupSocket         *soup_socket_server_new        (const gint          port);
153
154 SoupSocket         *soup_socket_server_accept     (SoupSocket         *socket);
155
156 SoupSocket         *soup_socket_server_try_accept (SoupSocket         *socket);
157
158 #endif /* SOUP_SOCKET_H */