public class Net extends Object
Modifier and Type | Class and Description |
---|---|
static class |
Net.NetUtils |
Modifier and Type | Field and Description |
---|---|
static String |
infraRedHostName
This is the host name associated with the infra-red port.
|
Constructor and Description |
---|
Net() |
Modifier and Type | Method and Description |
---|---|
static Socket |
acceptConnection(Handle handle,
ServerSocket ss) |
static Handle |
acceptConnection(ServerSocket ss) |
protected static void |
addToMap(Map dest,
String name,
Object value)
Use this to correctly add values as lists of strings.
|
static InetAddress |
fixLocalAddress(InetAddress address,
InetAddress defaultAddress) |
static InetAddress |
getInfraRedAddress() |
static InetAddress |
getLocalAddress(ServerSocket ss) |
static InetAddress |
getLocalAddress(ServerSocket ss,
InetAddress defaultTo) |
static InetAddress |
getLocalAddress(Socket s) |
static InetAddress |
getLocalAddress(Socket s,
InetAddress defaultTo) |
static InetAddress[] |
getLocalAddresses(boolean rescanHardware,
boolean ip4Only)
Try to find the list of all IP addresses held by the local host, but
not including the local loop backs
|
static InetAddress |
getLocalHost()
A "safer" version of InetAddress getLocalHost().
|
static Net.NetUtils |
getNetUtils() |
static Socket |
getNewSocket(Object host,
int port)
This is a Stoppable version of new Socket().
|
static InetAddress |
getRemoteAddress(Socket s) |
static InetAddress |
getRemoteAddress(Socket s,
InetAddress defaultTo) |
static boolean |
hasInfraRedPort()
Return if an infra-red port is available on the local host.
|
static OutputStream |
httpConnectToUpload(String URL,
Map sendProperties,
Map receivedProperties) |
static InputStream |
httpConnectToWrite(String URL,
String type,
Map sendProperties,
Map receivedProperties,
byte[] toSend,
int offset,
int length) |
static InputStream |
httpConnectToWrite(String URL,
String type,
Vector cookiesToSet,
PropertyList propertiesToSet,
PropertyList receivedProperties,
byte[] toSend,
int offset,
int length) |
static boolean |
isLoopbackAddress(InetAddress addr) |
static Socket |
newSocket(Handle handle,
Object host,
int port)
Deprecated.
use getNewSocket(Object host, int port)
|
static Handle |
newSocket(InetAddress host,
int port)
Create a new connected Socket in a separate thread.
|
static Handle |
newSocket(String host,
int port)
Create a new connected Socket in a separate thread.
|
static Socket[] |
pipe()
Create two sockets connected to each other on the local machine.
|
static Object |
startClientProxy(Class serverInterface,
Socket connectedSocket,
int callTimeOutInMillis)
Create a proxy object that implements serverInterface by making remote
calls to a server object at the other end of the connectedSocket.
|
static Handle |
startRemoteServer(Object serverObject,
Class serverInterface,
Socket connectedSocket,
int callTimeOutInMillis)
Start up a server that accepts Remote Method Invocation calls on the
provided connected socket.
|
static String |
toHostAddresses(InetAddress addr) |
static String |
toOneHostAddress(InetAddress addr) |
public static final String infraRedHostName
public static InetAddress getInfraRedAddress() throws UnknownHostException
UnknownHostException
- if no infra-red port is available.public static boolean hasInfraRedPort()
public static Socket newSocket(Handle handle, Object host, int port) throws UnknownHostException, IOException
handle
- host
- port
- UnknownHostException
IOException
public static Socket acceptConnection(Handle handle, ServerSocket ss) throws IOException
IOException
public static Handle newSocket(String host, int port)
host
- the host to connect to.port
- the port to connect to.public static Handle newSocket(InetAddress host, int port)
host
- the host to connect to.port
- the port to connect to.public static Handle acceptConnection(ServerSocket ss)
public static Socket[] pipe() throws IOException
IOException
public static String toOneHostAddress(InetAddress addr)
public static boolean isLoopbackAddress(InetAddress addr)
public static String toHostAddresses(InetAddress addr)
public static InetAddress[] getLocalAddresses(boolean rescanHardware, boolean ip4Only)
public static InetAddress getLocalHost() throws UnknownHostException
UnknownHostException
public static InetAddress fixLocalAddress(InetAddress address, InetAddress defaultAddress)
public static InetAddress getLocalAddress(ServerSocket ss, InetAddress defaultTo)
public static InetAddress getLocalAddress(ServerSocket ss)
public static InetAddress getLocalAddress(Socket s, InetAddress defaultTo)
public static InetAddress getLocalAddress(Socket s)
public static InetAddress getRemoteAddress(Socket s, InetAddress defaultTo)
public static InetAddress getRemoteAddress(Socket s)
public static Handle startRemoteServer(Object serverObject, Class serverInterface, Socket connectedSocket, int callTimeOutInMillis) throws IOException
serverObject
- the Object acting as the server.serverInterface
- the Interface the serverObject will implement.connectedSocket
- the connected socket.callTimeOutInMillis
- the length of time in milliseconds before
remote calls time out. A zero or negative value indicates that the
default should be used.IOException
- on any IO error.public static Object startClientProxy(Class serverInterface, Socket connectedSocket, int callTimeOutInMillis) throws IOException
serverInterface
- the Interface the serverObject will implement.connectedSocket
- the connected socket.callTimeOutInMillis
- the length of time in milliseconds before
remote calls time out. A zero or negative value indicates that the
default should be used.IOException
- on any IO error.public static Socket getNewSocket(Object host, int port) throws UnknownHostException, IOException, StoppedException
host
- a host name or an InetAddress.port
- the port to connect to.UnknownHostException
IOException
StoppedException
- if the Thread Handle was stopped.public static InputStream httpConnectToWrite(String URL, String type, Vector cookiesToSet, PropertyList propertiesToSet, PropertyList receivedProperties, byte[] toSend, int offset, int length) throws IOException, MalformedURLException
IOException
MalformedURLException
protected static void addToMap(Map dest, String name, Object value)
name
- the name of the property to add.value
- the value, which may be a String or a List of Strings.public static InputStream httpConnectToWrite(String URL, String type, Map sendProperties, Map receivedProperties, byte[] toSend, int offset, int length) throws IOException, MalformedURLException
IOException
MalformedURLException
public static OutputStream httpConnectToUpload(String URL, Map sendProperties, Map receivedProperties) throws IOException, MalformedURLException
IOException
MalformedURLException
public static Net.NetUtils getNetUtils()