Qore Programming Language  0.8.3
include/qore/QoreNet.h (4311)
00001 /* -*- mode: c++; indent-tabs-mode: nil -*- */
00002 /*
00003   QoreNet.h
00004 
00005   Network functions and macros
00006 
00007   Qore Programming Language
00008 
00009   Copyright 2003 - 2011 David Nichols
00010 
00011   This library is free software; you can redistribute it and/or
00012   modify it under the terms of the GNU Lesser General Public
00013   License as published by the Free Software Foundation; either
00014   version 2.1 of the License, or (at your option) any later version.
00015 
00016   This library is distributed in the hope that it will be useful,
00017   but WITHOUT ANY WARRANTY; without even the implied warranty of
00018   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00019   Lesser General Public License for more details.
00020 
00021   You should have received a copy of the GNU Lesser General Public
00022   License along with this library; if not, write to the Free Software
00023   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00024 */
00025 
00026 #ifndef _QORE_QORENET_H
00027 
00028 #define _QORE_QORENET_H
00029 
00030 #include <sys/types.h>
00031 
00033 
00035 DLLEXPORT int q_gethostbyname(const char *host, struct in_addr *sin_addr);
00036 
00038 DLLEXPORT QoreHashNode *q_gethostbyname_to_hash(const char *host);
00039 
00041 DLLEXPORT QoreStringNode *q_gethostbyname_to_string(const char *host);
00042 
00044 DLLEXPORT char *q_gethostbyaddr(const char *addr, int len, int type);
00045 
00047 DLLEXPORT QoreHashNode *q_gethostbyaddr_to_hash(ExceptionSink *xsink, const char *addr, int type = Q_AF_INET);
00048 
00050 DLLEXPORT QoreStringNode *q_gethostbyaddr_to_string(ExceptionSink *xsink, const char *addr, int type = Q_AF_INET);
00051 
00053 
00055 DLLEXPORT QoreStringNode *q_addr_to_string(int address_family, const char *addr);
00056 
00058 DLLEXPORT QoreStringNode *q_addr_to_string2(const struct sockaddr *ai_addr);
00059 
00061 DLLEXPORT int q_get_port_from_addr(const struct sockaddr *ai_addr);
00062 
00064 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);
00065 
00066 class QoreAddrInfo {
00067 protected:
00068    struct addrinfo *ai;
00069    bool has_svc;
00070 
00071 public:
00073    DLLEXPORT QoreAddrInfo();
00074 
00076    DLLEXPORT ~QoreAddrInfo();
00077 
00079    DLLEXPORT void clear();
00080 
00082 
00090    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);
00091 
00093    DLLLOCAL struct addrinfo *getAddrInfo() const {
00094       return ai;
00095    }
00096    
00098    DLLEXPORT QoreListNode *getList() const;   
00099 
00101    DLLEXPORT static const char *getFamilyName(int address_family);
00102 
00104    DLLEXPORT static QoreStringNode *getAddressDesc(int address_family, const char *addr);
00105 };
00106 
00107 #endif // _QORE_QORENET_H
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Defines