front_idill/extern/fajran-npTuioClient/TuioClient/oscpack/ip/IpEndpointName.h
author bastiena
Fri, 06 Apr 2012 10:44:54 +0200
changeset 21 e4e5f02787a1
child 28 9ccef81f02ab
permissions -rw-r--r--
Front IDILL : Added Communication extern named fajran-npTuioClient It contains the project generating a dll used as a browser plugin.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
21
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
     1
/*
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
     2
	oscpack -- Open Sound Control packet manipulation library
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
     3
	http://www.audiomulch.com/~rossb/oscpack
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
     4
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
     5
	Copyright (c) 2004-2005 Ross Bencina <rossb@audiomulch.com>
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
     6
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
     7
	Permission is hereby granted, free of charge, to any person obtaining
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
     8
	a copy of this software and associated documentation files
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
     9
	(the "Software"), to deal in the Software without restriction,
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    10
	including without limitation the rights to use, copy, modify, merge,
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    11
	publish, distribute, sublicense, and/or sell copies of the Software,
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    12
	and to permit persons to whom the Software is furnished to do so,
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    13
	subject to the following conditions:
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    14
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    15
	The above copyright notice and this permission notice shall be
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    16
	included in all copies or substantial portions of the Software.
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    17
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    18
	Any person wishing to distribute modifications to the Software is
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    19
	requested to send the modifications to the original developer so that
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    20
	they can be incorporated into the canonical version.
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    21
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    22
	THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    23
	EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    24
	MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    25
	IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    26
	ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    27
	CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    28
	WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    29
*/
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    30
#ifndef INCLUDED_IPENDPOINTNAME_H
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    31
#define INCLUDED_IPENDPOINTNAME_H
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    32
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    33
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    34
class IpEndpointName{
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    35
    static unsigned long GetHostByName( const char *s );
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    36
public:
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    37
    static const unsigned long ANY_ADDRESS = 0xFFFFFFFF;
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    38
    static const int ANY_PORT = -1;
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    39
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    40
    IpEndpointName()
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    41
		: address( ANY_ADDRESS ), port( ANY_PORT ) {}
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    42
    IpEndpointName( int port_ ) 
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    43
		: address( ANY_ADDRESS ), port( port_ ) {}
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    44
    IpEndpointName( unsigned long ipAddress_, int port_ ) 
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    45
		: address( ipAddress_ ), port( port_ ) {}
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    46
    IpEndpointName( const char *addressName, int port_=ANY_PORT )
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    47
		: address( GetHostByName( addressName ) )
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    48
		, port( port_ ) {}
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    49
    IpEndpointName( int addressA, int addressB, int addressC, int addressD, int port_=ANY_PORT )
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    50
		: address( ( (addressA << 24) | (addressB << 16) | (addressC << 8) | addressD ) )
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    51
		, port( port_ ) {}
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    52
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    53
	// address and port are maintained in host byte order here
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    54
    unsigned long address;
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    55
    int port;
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    56
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    57
	enum { ADDRESS_STRING_LENGTH=17 };
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    58
	void AddressAsString( char *s ) const;
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    59
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    60
	enum { ADDRESS_AND_PORT_STRING_LENGTH=23};
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    61
	void AddressAndPortAsString( char *s ) const;
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    62
};
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    63
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    64
inline bool operator==( const IpEndpointName& lhs, const IpEndpointName& rhs )
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    65
{	
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    66
	return (lhs.address == rhs.address && lhs.port == rhs.port );
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    67
}
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    68
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    69
inline bool operator!=( const IpEndpointName& lhs, const IpEndpointName& rhs )
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    70
{
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    71
	return !(lhs == rhs);
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    72
}
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    73
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    74
#endif /* INCLUDED_IPENDPOINTNAME_H */