p2ps.imp.net
Class NetworkFactory
java.lang.Object
p2ps.imp.net.NetworkFactory
- public class NetworkFactory
- extends java.lang.Object
A factory for interfacing the network architecture. The network factory allows
different network implementations to be plugged in rather than assuming everything
runs on top of the Internet as Java does.
- Version:
- $Revision: 295 $
- Author:
- Ian Wang
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
LOCALHOST
public static final java.lang.String LOCALHOST
- See Also:
- Constant Field Values
factory
public static NetworkInterface factory
NetworkFactory
public NetworkFactory()
getLocalHostAddress
public static java.lang.String getLocalHostAddress()
throws java.net.UnknownHostException
- Returns:
- the address of the local host as a String
- Throws:
java.net.UnknownHostException
getNetworkInterface
public static java.net.NetworkInterface getNetworkInterface(java.net.SocketAddress addr)
throws java.net.SocketException
- 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 static java.net.SocketAddress createSocketAddress(java.lang.String addr,
int port)
- Returns:
- a new socket address
createGroupAddress
public static java.net.SocketAddress createGroupAddress(int port)
- Returns:
- a group address with the specified port
createDiscoveryAddress
public static java.net.SocketAddress createDiscoveryAddress()
- Returns:
- a group address with the specified port
getHostAddress
public static java.lang.String getHostAddress(java.net.SocketAddress address)
- Returns:
- the host address from a socket address
getPort
public static int getPort(java.net.SocketAddress address)
- Returns:
- the port from a socket address
createServerSocket
public static ServerSocket createServerSocket(java.net.SocketAddress addr)
throws java.io.IOException
- Parameters:
addr - the address the socket is bound to
- Returns:
- a default server socket bound to the specified port
- Throws:
java.io.IOException
createServerSocket
public static ServerSocket createServerSocket(java.net.SocketAddress addr,
java.lang.String type,
java.util.Map properties)
throws java.io.IOException
- Parameters:
addr - the address the socket is bound totype - the type of server socketproperties - properties of the server socket
- Returns:
- a server socket bound to the specified port
- Throws:
java.io.IOException
createSocket
public static Socket createSocket(java.net.SocketAddress addr)
throws java.io.IOException
- Parameters:
addr - the address the socket is bound to
- Returns:
- a socket instance
- Throws:
java.io.IOException
createSocket
public static Socket createSocket(java.net.SocketAddress addr,
java.lang.String type,
java.util.Map properties)
throws java.io.IOException
- Parameters:
addr - the address the socket is bound totype - the type of socket instanceproperties - properties of the socket instance
- Returns:
- a socket instance
- Throws:
java.io.IOException
createDatagramSocket
public static DatagramSocket createDatagramSocket(java.net.SocketAddress addr)
throws java.io.IOException
- Parameters:
addr - the address the socket is bound to
- Returns:
- a datagram socket instance bound to the specified address
- Throws:
java.io.IOException
createDatagramSocket
public static DatagramSocket createDatagramSocket(java.net.SocketAddress addr,
java.lang.String type,
java.util.Map properties)
throws java.io.IOException
- Parameters:
addr - the address the socket is bound totype - the type of datagram socket instanceproperties - properties of the datagram socket instance
- Returns:
- a datagram socket instance
- Throws:
java.io.IOException
createMulticastSocket
public static MulticastSocket createMulticastSocket(java.net.SocketAddress addr)
throws java.io.IOException
- Parameters:
addr - the address the socket is bound to
- Returns:
- a multicast socket instance bound to the specified address
- Throws:
java.io.IOException
createMulticastSocket
public static MulticastSocket createMulticastSocket(java.net.SocketAddress addr,
java.lang.String type,
java.util.Map properties)
throws java.io.IOException
- Parameters:
addr - the address the socket is bound totype - the type of multicast socket instanceproperties - properties of the multicast socket instance
- Returns:
- a multicast socket instance
- Throws:
java.io.IOException