Main Page
Modules
Data Structures
Files
File List
Globals
All
Data Structures
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
modules
base
target
Linux-x86_64
include
citrusleaf
target/Linux-x86_64/include/citrusleaf/cf_socket.h
Go to the documentation of this file.
1
/******************************************************************************
2
* Copyright 2008-2013 by Aerospike.
3
*
4
* Permission is hereby granted, free of charge, to any person obtaining a copy
5
* of this software and associated documentation files (the "Software"), to
6
* deal in the Software without restriction, including without limitation the
7
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
8
* sell copies of the Software, and to permit persons to whom the Software is
9
* furnished to do so, subject to the following conditions:
10
*
11
* The above copyright notice and this permission notice shall be included in
12
* all copies or substantial portions of the Software.
13
*
14
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
20
* IN THE SOFTWARE.
21
*****************************************************************************/
22
#pragma once
23
24
#include <stddef.h>
25
#include <stdint.h>
26
27
#if defined(__linux__) || defined(__APPLE__)
28
#include <unistd.h>
29
#include <arpa/inet.h>
30
#include <netinet/in.h>
31
#include <sys/socket.h>
32
33
// Windows send() and recv() parameter types are different.
34
#define cf_socket_data_t void
35
#define cf_socket_size_t size_t
36
37
#define cf_close(fd) (close(fd))
38
39
//------------------------------------------------
40
// The API below is not used by the libevent2
41
// client, so we'll postpone the Windows version.
42
//
43
extern
int
44
cf_socket_read_timeout(
int
fd, uint8_t *buf,
size_t
buf_len, uint64_t trans_deadline,
int
attempt_ms);
45
extern
int
46
cf_socket_write_timeout(
int
fd, uint8_t *buf,
size_t
buf_len, uint64_t trans_deadline,
int
attempt_ms);
47
extern
int
48
cf_socket_read_forever(
int
fd, uint8_t *buf,
size_t
buf_len);
49
extern
int
50
cf_socket_write_forever(
int
fd, uint8_t *buf,
size_t
buf_len);
51
52
extern
void
53
cf_print_sockaddr_in(
char
*prefix,
struct
sockaddr_in *sa_in);
54
#endif
55
56
#if defined(__APPLE__)
57
#define MSG_NOSIGNAL SO_NOSIGPIPE
58
#endif
59
60
#if defined(CF_WINDOWS)
61
#include <WinSock2.h>
62
#include <Ws2tcpip.h>
63
64
#define cf_socket_data_t char
65
#define cf_socket_size_t int
66
67
#define cf_close(fd) (closesocket(fd))
68
69
#define MSG_DONTWAIT 0
70
#define MSG_NOSIGNAL 0
71
72
#define SHUT_RDWR SD_BOTH
73
#endif // CF_WINDOWS
74
75
76
extern
int
77
cf_socket_create_nb
();
78
extern
int
79
cf_socket_start_connect_nb
(
int
fd,
struct
sockaddr_in *sa);
80
extern
int
81
cf_socket_create_and_connect_nb
(
struct
sockaddr_in *sa);