]>
git.proxmox.com Git - ceph.git/blob - ceph/src/jaegertracing/thrift/lib/lua/src/socket.h
2 // Licensed to the Apache Software Foundation (ASF) under one
3 // or more contributor license agreements. See the NOTICE file
4 // distributed with this work for additional information
5 // regarding copyright ownership. The ASF licenses this file
6 // to you under the Apache License, Version 2.0 (the
7 // "License"); you may not use this file except in compliance
8 // with the License. You may obtain a copy of the License at
10 // http://www.apache.org/licenses/LICENSE-2.0
12 // Unless required by applicable law or agreed to in writing,
13 // software distributed under the License is distributed on an
14 // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 // KIND, either express or implied. See the License for the
16 // specific language governing permissions and limitations
20 #ifndef LUA_THRIFT_SOCKET_H
21 #define LUA_THRIFT_SOCKET_H
23 #include <sys/socket.h>
29 typedef t_socket
* p_socket
;
38 typedef int T_ERRCODE
;
40 static const char * TIMEOUT_MSG
= "Timeout";
41 static const char * CLOSED_MSG
= "Connection Closed";
43 typedef struct sockaddr t_sa
;
46 T_ERRCODE
socket_create(p_socket sock
, int domain
, int type
, int protocol
);
47 T_ERRCODE
socket_destroy(p_socket sock
);
48 T_ERRCODE
socket_bind(p_socket sock
, p_sa addr
, int addr_len
);
49 T_ERRCODE
socket_get_info(p_socket sock
, short *port
, char *buf
, size_t len
);
50 T_ERRCODE
socket_send(p_socket sock
, const char *data
, size_t len
, int timeout
);
51 T_ERRCODE
socket_recv(p_socket sock
, char *data
, size_t len
, int timeout
,
54 T_ERRCODE
socket_setblocking(p_socket sock
);
55 T_ERRCODE
socket_setnonblocking(p_socket sock
);
57 T_ERRCODE
socket_accept(p_socket sock
, p_socket sibling
,
58 p_sa addr
, socklen_t
*addr_len
, int timeout
);
59 T_ERRCODE
socket_listen(p_socket sock
, int backlog
);
61 T_ERRCODE
socket_connect(p_socket sock
, p_sa addr
, int addr_len
, int timeout
);
63 const char * tcp_create(p_socket sock
);
64 const char * tcp_destroy(p_socket sock
);
65 const char * tcp_bind(p_socket sock
, const char *host
, unsigned short port
);
66 const char * tcp_send(p_socket sock
, const char *data
, size_t w_len
,
68 const char * tcp_receive(p_socket sock
, char *data
, size_t r_len
, int timeout
);
69 const char * tcp_raw_receive(p_socket sock
, char * data
, size_t r_len
,
70 int timeout
, int *received
);
72 const char * tcp_listen(p_socket sock
, int backlog
);
73 const char * tcp_accept(p_socket sock
, p_socket client
, int timeout
);
75 const char * tcp_connect(p_socket sock
, const char *host
, unsigned short port
,