summaryrefslogtreecommitdiff
path: root/cpp/src/Ice/Network.h
blob: ac57f0b15ae61647e720ab53bca21c2ecb392e0a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
// **********************************************************************
//
// Copyright (c) 2002
// MutableRealms, Inc.
// Huntsville, AL, USA
//
// All Rights Reserved
//
// **********************************************************************

#ifndef ICE_NETWORK_H
#define ICE_NETWORK_H

#include <Ice/Config.h>

#ifdef _WIN32
#   include <winsock.h>
#else
#   include <unistd.h>
#   include <fcntl.h>
#   include <sys/socket.h>
#   include <sys/select.h>
#   include <netinet/in.h>
#   include <netinet/tcp.h>
#   include <arpa/inet.h>
#   include <netdb.h>
#endif

#ifdef _WIN32
typedef int socklen_t;
#endif

#ifndef _WIN32
#   define SOCKET int
#   define SOCKET_ERROR -1
#   define INVALID_SOCKET -1
#endif

#ifndef SHUT_RD
#   define SHUT_RD 0
#endif

#ifndef SHUT_WR
#   define SHUT_WR 1
#endif

#ifndef SHUT_RDWR
#   define SHUT_RDWR 2
#endif

#ifndef NETDB_INTERNAL
#   define NETDB_INTERNAL -1
#endif

#ifndef NETDB_SUCCESS
#   define NETDB_SUCCESS 0
#endif

namespace IceInternal
{

ICE_PROTOCOL_API bool interrupted();
ICE_PROTOCOL_API bool acceptInterrupted();
ICE_PROTOCOL_API bool noBuffers();
ICE_PROTOCOL_API bool wouldBlock();
ICE_PROTOCOL_API bool connectFailed();
ICE_PROTOCOL_API bool connectInProgress();
ICE_PROTOCOL_API bool connectionLost();
ICE_PROTOCOL_API bool notConnected();

ICE_PROTOCOL_API SOCKET createSocket(bool);
ICE_PROTOCOL_API void closeSocket(SOCKET);

ICE_PROTOCOL_API void setBlock(SOCKET, bool);
ICE_PROTOCOL_API void setTcpNoDelay(SOCKET);
ICE_PROTOCOL_API void setKeepAlive(SOCKET);
ICE_PROTOCOL_API void setSendBufferSize(SOCKET, int);

ICE_PROTOCOL_API void doBind(SOCKET, struct sockaddr_in&);
ICE_PROTOCOL_API void doListen(SOCKET, int);
ICE_PROTOCOL_API void doConnect(SOCKET, struct sockaddr_in&, int);
ICE_PROTOCOL_API SOCKET doAccept(SOCKET, int);

ICE_PROTOCOL_API void getAddress(const std::string&, int, struct sockaddr_in&);
ICE_PROTOCOL_API std::string getLocalHost(bool);
ICE_PROTOCOL_API bool compareAddress(const struct sockaddr_in&, const struct sockaddr_in&);

ICE_PROTOCOL_API void createPipe(SOCKET fds[2]);

ICE_PROTOCOL_API std::string errorToString(int);
ICE_PROTOCOL_API std::string errorToStringDNS(int);
ICE_PROTOCOL_API std::string lastErrorToString();
ICE_PROTOCOL_API std::string lastErrorToStringDNS();

ICE_PROTOCOL_API std::string fdToString(SOCKET);
ICE_PROTOCOL_API std::string addrToString(const struct sockaddr_in&);

}

#endif