GRPC Core  0.11.0.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
udp_server.h
Go to the documentation of this file.
1 /*
2  *
3  * Copyright 2015, Google Inc.
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions are
8  * met:
9  *
10  * * Redistributions of source code must retain the above copyright
11  * notice, this list of conditions and the following disclaimer.
12  * * Redistributions in binary form must reproduce the above
13  * copyright notice, this list of conditions and the following disclaimer
14  * in the documentation and/or other materials provided with the
15  * distribution.
16  * * Neither the name of Google Inc. nor the names of its
17  * contributors may be used to endorse or promote products derived from
18  * this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  *
32  */
33 
34 #ifndef GRPC_INTERNAL_CORE_IOMGR_UDP_SERVER_H
35 #define GRPC_INTERNAL_CORE_IOMGR_UDP_SERVER_H
36 
38 
39 /* Forward decl of grpc_udp_server */
41 
42 /* New server callback: ep is the newly connected connection */
43 typedef void (*grpc_udp_server_cb)(void *arg, grpc_endpoint *ep);
44 
45 /* Called when data is available to read from the socket. */
46 typedef void (*grpc_udp_server_read_cb)(int fd,
47  grpc_udp_server_cb new_transport_cb,
48  void *cb_arg);
49 
50 /* Create a server, initially not bound to any ports */
52 
53 /* Start listening to bound ports */
54 void grpc_udp_server_start(grpc_udp_server *server, grpc_pollset **pollsets,
55  size_t pollset_count, grpc_udp_server_cb cb,
56  void *cb_arg);
57 
58 int grpc_udp_server_get_fd(grpc_udp_server *s, unsigned index);
59 
60 /* Add a port to the server, returning port number on success, or negative
61  on failure.
62 
63  The :: and 0.0.0.0 wildcard addresses are treated identically, accepting
64  both IPv4 and IPv6 connections, but :: is the preferred style. This usually
65  creates one socket, but possibly two on systems which support IPv6,
66  but not dualstack sockets. */
67 
68 /* TODO(ctiller): deprecate this, and make grpc_udp_server_add_ports to handle
69  all of the multiple socket port matching logic in one place */
70 int grpc_udp_server_add_port(grpc_udp_server *s, const void *addr, int addr_len,
71  grpc_udp_server_read_cb read_cb);
72 
74  void (*shutdown_done)(void *shutdown_done_arg),
75  void *shutdown_done_arg);
76 
77 /* Write the contents of buffer to the underlying UDP socket. */
78 /*
79 void grpc_udp_server_write(grpc_udp_server *s,
80  const char *buffer,
81  int buf_len,
82  const struct sockaddr* to);
83  */
84 
85 #endif /* GRPC_INTERNAL_CORE_IOMGR_UDP_SERVER_H */
grpc_udp_server * grpc_udp_server_create(void)
void(* grpc_udp_server_read_cb)(int fd, grpc_udp_server_cb new_transport_cb, void *cb_arg)
Definition: udp_server.h:46
Definition: pollset_posix.h:55
void(* grpc_udp_server_cb)(void *arg, grpc_endpoint *ep)
Definition: udp_server.h:43
int grpc_udp_server_add_port(grpc_udp_server *s, const void *addr, int addr_len, grpc_udp_server_read_cb read_cb)
int grpc_udp_server_get_fd(grpc_udp_server *s, unsigned index)
struct arg arg
struct grpc_udp_server grpc_udp_server
Definition: udp_server.h:40
void grpc_udp_server_start(grpc_udp_server *server, grpc_pollset **pollsets, size_t pollset_count, grpc_udp_server_cb cb, void *cb_arg)
void grpc_udp_server_destroy(grpc_udp_server *server, void(*shutdown_done)(void *shutdown_done_arg), void *shutdown_done_arg)
Definition: endpoint.h:102