- Main Page
- Classes
- Files

- Search for |

# inetaddr.h

    00001 /*****************************
    00002 File:      inetaddr.h
    00003 Language:   C++ (header)
    00004 Project:    H3DNetworkingUtils
    00005 The contents of this file are subject to the Mozilla Public License
    00006 Version 1.1 (the "License"); you may not use this file except in
    00007 compliance with the License. You may obtain a copy of the License at
    00008 http://www.mozilla.org/MPL/
    00009
    00010 Software distributed under the License is distributed on an "AS IS"
    00011 basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
    00012 License for the specific language governing rights and limitations
    00013 under the License.
    00014
    00015 The Original Code is H3DNetworkingUtils v1.0.
    00016
    00017 The Initial Developer of the Original Code is ANU.
    00018 Portions created by the Initial Developer are Copyright (C) 1009 CSIRO. All Rights Reserved.
    00019 Contributor(s):
    00020     Samuel Taylor, (sam.taylor@anu.edu.au)
    00021     Chris Gunn  <Chris.Gunn@csiro.au> <ChrisJGunn@gmail.com>
    00022 ***************************/
    00023
    00025
    00026 #ifndef _inetaddr_
    00027 #define _inetaddr_
    00028
    00029 #ifdef _WIN32
    00030 #include <winsock.h>
    00031 #else
    00032 #include <sys/socket.h>
    00033 #include <netinet/in.h>
    00034 #endif
    00035 #include "H3DNetworkingUtils/Config.h"
    00036
    00037 class H3D_NETWORKING_UTILS_DLL_SPEC  InetAddr {
    00038   protected:
    00039     struct sockaddr_in address;
    00040     char   addressStr[24]; // Dotted IP plus : plus port
    00041
    00042   public:
    00043     InetAddr ();
    00044     virtual ~InetAddr ();
    00045
    00046     virtual int family ();
    00047     virtual int port ();
    00048     virtual void setPort (int newPort);
    00049
    00050     // Pointer to sin_addr field of address, for passing
    00051     // to socket functions and inet_ntop/pton functions.
    00052     virtual void * addr ();
    00053     virtual int    addrSize ();
    00054
    00055     // Construct address from string representation.
    00056     // Addr: Host/Port or Host:Port
    00057     // Host: name or dotted IP
    00058     // Port: number or registered service name
    00059     virtual void scan (char * addr);
    00060
    00061     virtual void scanHost (char * host);
    00062     virtual void scanPort (char * port);
    00063
    00064     // Copy
    00065     virtual InetAddr * clone ();
    00066
    00067     // Presentation format for output
    00068     virtual char * text ();
    00069
    00070     // Attributes
    00071     virtual int isUnicast ();
    00072     virtual int isMulticast ();
    00073     virtual int isLocal ();
    00074
    00075     // testing
    00076     virtual int eqHost (InetAddr * other);
    00077     virtual int eqPort (InetAddr * other);
    00078
    00079     // Handy call. Returns unqualified host name
    00080     static char * HostName ();
    00081 };
    00082
    00083 #endif