You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifdef HAVE_CONFIG_H
#include <simgear/structure/exception.hxx>
#include <simgear/threads/SGThread.hxx>
+using std::string;
+
namespace {
class Resolver : public SGThread
const char* IPAddress::getHost () const
{
+ if (!addr) {
+ return NULL;
+ }
+
static char buf [32];
long x = ntohl(addr->sin_addr.s_addr);
sprintf(buf, "%d.%d.%d.%d",
unsigned int IPAddress::getIP () const
{
+ if (!addr) {
+ return 0;
+ }
+
return addr->sin_addr.s_addr;
}
unsigned int IPAddress::getPort() const
{
+ if (!addr) {
+ return 0;
+ }
+
return ntohs(addr->sin_port);
}
void IPAddress::setPort(int port)
{
+ if (!addr) {
+ return;
+ }
+
addr->sin_port = htons(port);
}
unsigned int IPAddress::getFamily () const
{
+ if (!addr) {
+ return 0;
+ }
+
return addr->sin_family;
}
bool IPAddress::getBroadcast () const
{
- return (addr->sin_addr.s_addr == INADDR_BROADCAST);
+ if (!addr) {
+ return false;
+ }
+
+ return (addr->sin_addr.s_addr == INADDR_BROADCAST);
}
unsigned int IPAddress::getAddrLen() const
return (struct sockaddr*) addr;
}
+bool IPAddress::isValid() const
+{
+ return (addr != NULL);
+}
+
Socket::Socket ()
{
handle = -1 ;