net.h

Go to the documentation of this file.
00001 /****************************************************************
00002  *  Vidalia is distributed under the following license:
00003  *
00004  *  Copyright (C) 2006,  Matt Edman, Justin Hipple
00005  *
00006  *  This program is free software; you can redistribute it and/or
00007  *  modify it under the terms of the GNU General Public License
00008  *  as published by the Free Software Foundation; either version 2
00009  *  of the License, or (at your option) any later version.
00010  *
00011  *  This program is distributed in the hope that it will be useful,
00012  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  *  GNU General Public License for more details.
00015  *
00016  *  You should have received a copy of the GNU General Public License
00017  *  along with this program; if not, write to the Free Software
00018  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, 
00019  *  Boston, MA  02110-1301, USA.
00020  ****************************************************************/
00021 
00022 /** 
00023  * \file net.h
00024  * \version $Id: net.h 1238 2006-09-25 17:50:57Z edmanm $
00025  * \brief Common network I/O and utility functions
00026  */
00027 
00028 #ifndef _NET_H
00029 #define _NET_H
00030 
00031 #include <QHostAddress>
00032 
00033 /** Returns the local machine's IP address. */
00034 QHostAddress net_local_address();
00035 
00036 /** Returns true if the given address is a private IP. */
00037 bool net_is_private_address(QHostAddress addr);
00038 
00039 /** Returns true if the given IP address is a valid IPv4 address. */
00040 bool net_is_valid_ip(QString ip);
00041 
00042 /** Tries to determine this machine's external IP. */
00043 bool net_get_public_ip(QString &ip);
00044 
00045 /** Attempts a connection to <b>host</b> on <b>port</b>. Returns true if the
00046  * connection was successful, or false if the connection attempt failed. */
00047 bool net_test_connect(QHostAddress host, quint16 port, int timeout = 250);
00048 
00049 #endif
00050 

Generated on Mon Oct 23 20:08:16 2006 for Vidalia by  doxygen 1.5.0