Debian Codegraph @

c/src/reactor/io.h

raw
1 #ifndef PROTON_IO_H
2 #define PROTON_IO_H 1
3
4 /*
5 *
6 * Licensed to the Apache Software Foundation (ASF) under one
7 * or more contributor license agreements. See the NOTICE file
8 * distributed with this work for additional information
9 * regarding copyright ownership. The ASF licenses this file
10 * to you under the Apache License, Version 2.0 (the
11 * "License"); you may not use this file except in compliance
12 * with the License. You may obtain a copy of the License at
13 *
14 * http://www.apache.org/licenses/LICENSE-2.0
15 *
16 * Unless required by applicable law or agreed to in writing,
17 * software distributed under the License is distributed on an
18 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
19 * KIND, either express or implied. See the License for the
20 * specific language governing permissions and limitations
21 * under the License.
22 *
23 */
24
25 #include "selector.h"
26
27 #include <proton/import_export.h>
28 #include <proton/error.h>
29 #include <proton/type_compat.h>
30 #include <stddef.h>
31
32 /**
33 * A ::pn_io_t manages IO for a group of pn_socket_t handles. A
34 * pn_io_t object may have zero or one pn_selector_t selectors
35 * associated with it (see ::pn_io_selector()). If one is associated,
36 * all the pn_socket_t handles managed by a pn_io_t must use that
37 * pn_selector_t instance.
38 *
39 * The pn_io_t interface is single-threaded. All methods are intended
40 * to be used by one thread at a time, except that multiple threads
41 * may use:
42 *
43 * ::pn_write()
44 * ::pn_send()
45 * ::pn_recv()
46 * ::pn_close()
47 * ::pn_selector_select()
48 *
49 * provided at most one thread is calling ::pn_selector_select() and
50 * the other threads are operating on separate pn_socket_t handles.
51 */
52 typedef struct pn_io_t pn_io_t;
53
54 pn_io_t *pn_io(void);
55 void pn_io_free(pn_io_t *io);
56 pn_error_t *pn_io_error(pn_io_t *io);
57 pn_socket_t pn_connect(pn_io_t *io, const char *host, const char *port);
58 pn_socket_t pn_listen(pn_io_t *io, const char *host, const char *port);
59
60 pn_socket_t pn_accept(pn_io_t *io, pn_socket_t socket, char *name, size_t size);
61 void pn_close(pn_io_t *io, pn_socket_t socket);
62 ssize_t pn_send(pn_io_t *io, pn_socket_t socket, const void *buf, size_t size);
63 ssize_t pn_recv(pn_io_t *io, pn_socket_t socket, void *buf, size_t size);
64 int pn_pipe(pn_io_t *io, pn_socket_t *dest);
65 ssize_t pn_read(pn_io_t *io, pn_socket_t socket, void *buf, size_t size);
66 ssize_t pn_write(pn_io_t *io, pn_socket_t socket, const void *buf, size_t size);
67 bool pn_wouldblock(pn_io_t *io);
68 pn_selector_t *pn_io_selector(pn_io_t *io);
69
70 #endif /* io.h */