p2ps.imp.net.inet
Class InetNetworkInterface

java.lang.Object
  extended byp2ps.imp.net.inet.InetNetworkInterface
All Implemented Interfaces:
NetworkInterface

public class InetNetworkInterface
extends java.lang.Object
implements NetworkInterface

An interface to the Internet. This is the default network binding.

Version:
$Revision: 295 $
Author:
Ian Wang

Nested Class Summary
 class InetNetworkInterface.ExtendedKeyManager
           
 
Field Summary
static java.lang.String DISCOVERY_ADDR
           
static int DISCOVERY_PORT
           
 
Fields inherited from interface p2ps.imp.net.NetworkInterface
DEFAULT_SOCKET_TYPE, SSL_SOCKET_TYPE
 
Constructor Summary
InetNetworkInterface()
           
 
Method Summary
 DatagramSocket createDatagramSocket(java.net.SocketAddress addr, java.lang.String type, java.util.Map properties)
           
 java.net.SocketAddress createDiscoveryAddress()
           
 java.net.SocketAddress createGroupAddress(int port)
           
 MulticastSocket createMulticastSocket(java.net.SocketAddress addr, java.lang.String type, java.util.Map properties)
           
 ServerSocket createServerSocket(java.net.SocketAddress addr, java.lang.String type, java.util.Map properties)
           
 Socket createSocket(java.net.SocketAddress addr, java.lang.String type, java.util.Map properties)
           
 java.net.SocketAddress createSocketAddress(java.lang.String addr, int port)
           
 java.lang.String getHostAddress(java.net.SocketAddress address)
           
 java.lang.String getLocalHostAddress()
           
 java.net.NetworkInterface getNetworkInterface(java.net.SocketAddress addr)
           
 int getPort(java.net.SocketAddress address)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DISCOVERY_ADDR

public static java.lang.String DISCOVERY_ADDR

DISCOVERY_PORT

public static int DISCOVERY_PORT
Constructor Detail

InetNetworkInterface

public InetNetworkInterface()
Method Detail

getLocalHostAddress

public java.lang.String getLocalHostAddress()
                                     throws java.net.UnknownHostException
Specified by:
getLocalHostAddress in interface NetworkInterface
Returns:
the address of the local host as a String
Throws:
java.net.UnknownHostException

getNetworkInterface

public java.net.NetworkInterface getNetworkInterface(java.net.SocketAddress addr)
                                              throws java.net.SocketException
Specified by:
getNetworkInterface in interface NetworkInterface
Returns:
the java.net network interface that owns the specified socket address. In non-java.net interfaces this method can probably return null.
Throws:
java.net.SocketException

createSocketAddress

public java.net.SocketAddress createSocketAddress(java.lang.String addr,
                                                  int port)
Specified by:
createSocketAddress in interface NetworkInterface
Returns:
a new socket address

createGroupAddress

public java.net.SocketAddress createGroupAddress(int port)
Specified by:
createGroupAddress in interface NetworkInterface
Returns:
a group address with the specified port

createDiscoveryAddress

public java.net.SocketAddress createDiscoveryAddress()
Specified by:
createDiscoveryAddress in interface NetworkInterface
Returns:
the discovery group address

getHostAddress

public java.lang.String getHostAddress(java.net.SocketAddress address)
Specified by:
getHostAddress in interface NetworkInterface
Returns:
the host address from a socket address

getPort

public int getPort(java.net.SocketAddress address)
Specified by:
getPort in interface NetworkInterface
Returns:
the port from a socket address

createServerSocket

public ServerSocket createServerSocket(java.net.SocketAddress addr,
                                       java.lang.String type,
                                       java.util.Map properties)
                                throws java.io.IOException
Specified by:
createServerSocket in interface NetworkInterface
Parameters:
addr -
type - the type of server socket
properties - properties of the server socket
Returns:
a server socket bound to the specified port
Throws:
java.io.IOException

createSocket

public Socket createSocket(java.net.SocketAddress addr,
                           java.lang.String type,
                           java.util.Map properties)
                    throws java.io.IOException
Specified by:
createSocket in interface NetworkInterface
Parameters:
addr -
type - the type of socket instance
properties - properties of the socket instance
Returns:
a socket instance
Throws:
java.io.IOException

createDatagramSocket

public DatagramSocket createDatagramSocket(java.net.SocketAddress addr,
                                           java.lang.String type,
                                           java.util.Map properties)
                                    throws java.io.IOException
Specified by:
createDatagramSocket in interface NetworkInterface
Parameters:
addr -
type - the type of datagram socket instance
properties - properties of the datagram socket instance
Returns:
a datagram socket instance
Throws:
java.io.IOException

createMulticastSocket

public MulticastSocket createMulticastSocket(java.net.SocketAddress addr,
                                             java.lang.String type,
                                             java.util.Map properties)
                                      throws java.io.IOException
Specified by:
createMulticastSocket in interface NetworkInterface
Parameters:
addr -
type - the type of multicast socket instance
properties - properties of the multicast socket instance
Returns:
a multicast socket instance
Throws:
java.io.IOException