#ifndef _KIPADDRESSINUSEH #define _IKPADDRESSINUSEH /********************************************************************** * * kipaddressinuse.h - rev1 * Copyright (C) 2010 Guy Maurel * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * Send comments and bug fixes to the address above * *********************************************************************/ #include #include #include /** @brief example of use * works with IP-V4 and IP-V6 * make a variable such as * * QString addr; * * catch the IP-address actually used, ie. from the connection/ socket * transformed as a QString, in the format: * IP-V4: 192.168.2.20 * IP-V6: fe80::230:5ff:fed2:39a2 * * addr = < something from the connection >.toString(); * * Initialize and save the address * * KIpAddressInUse theAddressWeUse; * theAddressWeUse.saveAddressInUse ( addr); * * before each read/write, check if the address is still available * * if ( ! theAddressWeUse.isSavedAddressStillAvailable()) { * theAddressWeUse.resetAddressInUse (); * < take some decisions... > * } * < go on > */ class KIpAddressInUse { public: KIpAddressInUse (); virtual ~ KIpAddressInUse (); void saveAddressInUse ( QString ); void resetAddressInUse (); bool isSavedAddressStillAvailable(); private: QString savedIpAddress; }; #endif