GRPC Core  9.0.0
tcp_custom.h
Go to the documentation of this file.
1 /*
2  *
3  * Copyright 2018 gRPC authors.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  */
18 
19 #ifndef GRPC_CORE_LIB_IOMGR_TCP_CUSTOM_H
20 #define GRPC_CORE_LIB_IOMGR_TCP_CUSTOM_H
21 
23 
26 
29 
30 typedef struct grpc_custom_socket {
31  // Implementation defined
32  void* impl;
36  int refs;
38 
40  grpc_error* error);
42  grpc_error* error);
44  size_t nread, grpc_error* error);
46  grpc_custom_socket* client,
47  grpc_error* error);
49 
50 typedef struct grpc_socket_vtable {
51  grpc_error* (*init)(grpc_custom_socket* socket, int domain);
52  void (*connect)(grpc_custom_socket* socket, const grpc_sockaddr* addr,
53  size_t len, grpc_custom_connect_callback cb);
54  void (*destroy)(grpc_custom_socket* socket);
55  void (*shutdown)(grpc_custom_socket* socket);
57  void (*write)(grpc_custom_socket* socket, grpc_slice_buffer* slices,
59  void (*read)(grpc_custom_socket* socket, char* buffer, size_t length,
61  grpc_error* (*getpeername)(grpc_custom_socket* socket,
62  const grpc_sockaddr* addr, int* len);
63  grpc_error* (*getsockname)(grpc_custom_socket* socket,
64  const grpc_sockaddr* addr, int* len);
65  grpc_error* (*bind)(grpc_custom_socket* socket, const grpc_sockaddr* addr,
66  size_t len, int flags);
67  grpc_error* (*listen)(grpc_custom_socket* socket);
68  void (*accept)(grpc_custom_socket* socket, grpc_custom_socket* client,
71 
72 /* Internal APIs */
74 
76 
78  grpc_resource_quota* resource_quota,
79  char* peer_string);
80 
81 #endif /* GRPC_CORE_LIB_IOMGR_TCP_CUSTOM_H */
void(* write)(grpc_custom_socket *socket, grpc_slice_buffer *slices, grpc_custom_write_callback cb)
Definition: tcp_custom.h:57
void(* accept)(grpc_custom_socket *socket, grpc_custom_socket *client, grpc_custom_accept_callback cb)
Definition: tcp_custom.h:68
void * impl
Definition: tcp_custom.h:32
Definition: tcp_custom.h:30
int refs
Definition: tcp_custom.h:36
void(* grpc_custom_close_callback)(grpc_custom_socket *socket)
Definition: tcp_custom.h:48
Definition: error_internal.h:39
void(* connect)(grpc_custom_socket *socket, const grpc_sockaddr *addr, size_t len, grpc_custom_connect_callback cb)
Definition: tcp_custom.h:52
grpc_custom_tcp_connect * connector
Definition: tcp_custom.h:35
Represents an expandable array of slices, to be interpreted as a single item.
Definition: slice.h:78
void(* destroy)(grpc_custom_socket *socket)
Definition: tcp_custom.h:54
grpc_endpoint * custom_tcp_endpoint_create(grpc_custom_socket *socket, grpc_resource_quota *resource_quota, char *peer_string)
Definition: tcp_custom.cc:347
void(* shutdown)(grpc_custom_socket *socket)
Definition: tcp_custom.h:55
void(* grpc_custom_accept_callback)(grpc_custom_socket *socket, grpc_custom_socket *client, grpc_error *error)
Definition: tcp_custom.h:45
void(* grpc_custom_connect_callback)(grpc_custom_socket *socket, grpc_error *error)
Definition: tcp_custom.h:39
Definition: tcp_client_custom.cc:38
void(* close)(grpc_custom_socket *socket, grpc_custom_close_callback cb)
Definition: tcp_custom.h:56
void(* grpc_custom_read_callback)(grpc_custom_socket *socket, size_t nread, grpc_error *error)
Definition: tcp_custom.h:43
void grpc_custom_endpoint_init(grpc_socket_vtable *impl)
Definition: tcp_custom.cc:49
grpc_endpoint * endpoint
Definition: tcp_custom.h:33
struct grpc_socket_vtable grpc_socket_vtable
Definition: tcp_server_custom.cc:42
Definition: endpoint.h:102
void grpc_custom_close_server_callback(grpc_tcp_listener *listener)
Definition: tcp_server_custom.cc:157
Definition: resource_quota.cc:125
struct grpc_custom_socket grpc_custom_socket
void(* grpc_custom_write_callback)(grpc_custom_socket *socket, grpc_error *error)
Definition: tcp_custom.h:41
grpc_tcp_listener * listener
Definition: tcp_custom.h:34
Definition: tcp_custom.h:50
void(* read)(grpc_custom_socket *socket, char *buffer, size_t length, grpc_custom_read_callback cb)
Definition: tcp_custom.h:59