Qore Programming Language 0.8.8

- Main Page
- Related Pages
- Modules
- Classes
- Files

- File List
- File Members

All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
QoreNet.h
1 /* -*- mode: c++; indent-tabs-mode: nil -*- */
2 /*
3 QoreNet.h
4
5 Network functions and macros
6
7 Qore Programming Language
8
9 Copyright 2003 - 2013 David Nichols
10
11 This library is free software; you can redistribute it and/or
12 modify it under the terms of the GNU Lesser General Public
13 License as published by the Free Software Foundation; either
14 version 2.1 of the License, or (at your option) any later version.
15
16 This library is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 Lesser General Public License for more details.
20
21 You should have received a copy of the GNU Lesser General Public
22 License along with this library; if not, write to the Free Software
23 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24 */
25
26 #ifndef _QORE_QORENET_H
27
28 #define _QORE_QORENET_H
29
30 #include <sys/types.h>
31
33
35 DLLEXPORT int q_gethostbyname(const char *host, struct in_addr *sin_addr);
36
38 DLLEXPORT QoreHashNode *q_gethostbyname_to_hash(const char *host);
39
41 DLLEXPORT QoreStringNode *q_gethostbyname_to_string(const char *host);
42
44 DLLEXPORT char *q_gethostbyaddr(const char *addr, int len, int type);
45
47 DLLEXPORT QoreHashNode *q_gethostbyaddr_to_hash(ExceptionSink *xsink, const char *addr, int type = Q_AF_INET);
48
50 DLLEXPORT QoreStringNode *q_gethostbyaddr_to_string(ExceptionSink *xsink, const char *addr, int type = Q_AF_INET);
51
53
55 DLLEXPORT QoreStringNode *q_addr_to_string(int address_family, const char *addr);
56
58
66 DLLEXPORT int q_addr_to_string(int address_family, const char* addr, QoreString& str);
67
69 DLLEXPORT QoreStringNode *q_addr_to_string2(const struct sockaddr *ai_addr);
70
72
79 DLLEXPORT int q_addr_to_string2(const struct sockaddr *ai_addr, QoreString& str);
80
82 DLLEXPORT int q_get_port_from_addr(const struct sockaddr *ai_addr);
83
85 DLLEXPORT QoreListNode *q_getaddrinfo_to_list(ExceptionSink *xsink, const char *node, const char *service, int family = Q_AF_UNSPEC, int flags = 0, int socktype = Q_SOCK_STREAM);
86
88 DLLEXPORT void q_af_to_hash(int af, QoreHashNode& h, ExceptionSink* xsink);
89
91 class QoreAddrInfo {
92 protected:
93 struct addrinfo *ai;
94 bool has_svc;
95
96 public:
98 DLLEXPORT QoreAddrInfo();
99
101 DLLEXPORT ~QoreAddrInfo();
102
104 DLLEXPORT void clear();
105
107
115 DLLEXPORT int getInfo(ExceptionSink *xsink, const char *node, const char *service, int family = Q_AF_UNSPEC, int flags = 0, int socktype = Q_SOCK_STREAM, int protocol = 0);
116
118 DLLLOCAL struct addrinfo *getAddrInfo() const {
119 return ai;
120 }
121
123 DLLEXPORT QoreListNode *getList() const;
124
126 DLLEXPORT static const char *getFamilyName(int address_family);
127
129 DLLEXPORT static QoreStringNode *getAddressDesc(int address_family, const char *addr);
130 };
131
132 #endif // _QORE_QORENET_H
Q_SOCK_STREAM
#define Q_SOCK_STREAM
platform-independent define for SOCK_STREAM
Definition: common.h:55
QoreAddrInfo::QoreAddrInfo
DLLEXPORT QoreAddrInfo()
create an empty structure
QoreHashNode
This is the hash or associative list container type in Qore, dynamically allocated only...
Definition: QoreHashNode.h:41
QoreAddrInfo::getAddrInfo
DLLLOCAL struct addrinfo * getAddrInfo() const
returns the struct addrinfo * being managed (may by 0)
Definition: QoreNet.h:118
QoreAddrInfo::getList
DLLEXPORT QoreListNode * getList() const
returns a list of hashes of address info, if an addrinfo structure is being managed ...
Q_AF_INET
#define Q_AF_INET
cross-platform define for AF_INET
Definition: common.h:49
QoreAddrInfo::getInfo
DLLEXPORT int getInfo(ExceptionSink *xsink, const char *node, const char *service, int family=Q_AF_UNSPEC, int flags=0, int socktype=Q_SOCK_STREAM, int protocol=0)
get address info with the given parameters, if any errors occur, a Qore-language exception is thrown ...
QoreAddrInfo::clear
DLLEXPORT void clear()
clears the current results, if any
QoreAddrInfo
provides an interface to getaddrinfo
Definition: QoreNet.h:91
QoreString
Qore&#39;s string type supported by the QoreEncoding class.
Definition: QoreString.h:42
QoreStringNode
Qore&#39;s string value type, reference counted, dynamically-allocated only.
Definition: QoreStringNode.h:40
QoreAddrInfo::getFamilyName
static DLLEXPORT const char * getFamilyName(int address_family)
returns the name of the address family as a string (ie AF_INET = &quot;ipv4&quot;, etc)
QoreListNode
This is the list container type in Qore, dynamically allocated only, reference counted.
Definition: QoreListNode.h:44
ExceptionSink
container for holding Qore-language exception information and also for registering a &quot;thread_exit&quot; ca...
Definition: ExceptionSink.h:35
QoreAddrInfo::~QoreAddrInfo
DLLEXPORT ~QoreAddrInfo()
destroy the object
QoreAddrInfo::getAddressDesc
static DLLEXPORT QoreStringNode * getAddressDesc(int address_family, const char *addr)
returns a descriptive string for the address family and an address string (ie AF_INET6, &quot;::1&quot; = &quot;ipv6[::1]&quot;)
Q_AF_UNSPEC
#define Q_AF_UNSPEC
cross-platform define for AF_UNSPEC
Definition: common.h:46