All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
QoreNet.h
/* -*- mode: c++; indent-tabs-mode: nil -*- */
/*
QoreNet.h
Network functions and macros
Qore Programming Language
Copyright 2003 - 2013 David Nichols
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef _QORE_QORENET_H
#define _QORE_QORENET_H
#include <sys/types.h>
DLLEXPORT int q_gethostbyname(const char *host, struct in_addr *sin_addr);
DLLEXPORT QoreHashNode *q_gethostbyname_to_hash(const char *host);
DLLEXPORT QoreStringNode *q_gethostbyname_to_string(const char *host);
DLLEXPORT char *q_gethostbyaddr(const char *addr, int len, int type);
DLLEXPORT QoreHashNode *q_gethostbyaddr_to_hash(ExceptionSink *xsink, const char *addr, int type = Q_AF_INET);
DLLEXPORT QoreStringNode *q_gethostbyaddr_to_string(ExceptionSink *xsink, const char *addr, int type = Q_AF_INET);
DLLEXPORT QoreStringNode *q_addr_to_string(int address_family, const char *addr);
DLLEXPORT int q_addr_to_string(int address_family, const char* addr, QoreString& str);
DLLEXPORT QoreStringNode *q_addr_to_string2(const struct sockaddr *ai_addr);
DLLEXPORT int q_addr_to_string2(const struct sockaddr *ai_addr, QoreString& str);
DLLEXPORT int q_get_port_from_addr(const struct sockaddr *ai_addr);
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);
DLLEXPORT void q_af_to_hash(int af, QoreHashNode& h, ExceptionSink* xsink);
class QoreAddrInfo {
protected:
struct addrinfo *ai;
bool has_svc;
public:
DLLEXPORT QoreAddrInfo();
DLLEXPORT ~QoreAddrInfo();
DLLEXPORT void clear();
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);
DLLLOCAL struct addrinfo *getAddrInfo() const {
return ai;
}
DLLEXPORT QoreListNode *getList() const;
DLLEXPORT static const char *getFamilyName(int address_family);
DLLEXPORT static QoreStringNode *getAddressDesc(int address_family, const char *addr);
};
#endif // _QORE_QORENET_H