|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectibis.util.IbisSocketFactory
Abstract socket factory class for creating client and server sockets.
An implementation can be chosen by means of the
ibis.util.socketfactory
system property. If not set,
a default implementation is chosen.
Method Summary | |
java.net.Socket |
accept(java.net.ServerSocket a)
Accepts a connection to the specified server socket, and returns the resulting socket. |
int |
allocLocalPort()
Returns a port number. |
void |
close(java.io.InputStream in,
java.io.OutputStream out,
java.net.Socket s)
Closes a socket and streams that are associated with it. |
java.net.Socket |
createBrokeredSocket(java.io.InputStream in,
java.io.OutputStream out,
boolean isServer,
ibis.connect.socketFactory.ConnectionPropertiesProvider p)
Creates a brokered socket, using the specified streams to negotiate and determine addresses. |
java.net.Socket |
createBrokeredSocket(java.net.Socket s,
boolean isServer,
ibis.connect.socketFactory.ConnectionPropertiesProvider p)
Creates a brokered socket, using the specified socket to negotiate. |
static IbisSocketFactory |
createFactory()
Creates an IbisSocketFactory . |
abstract java.net.ServerSocket |
createServerSocket(int port,
java.net.InetAddress localAddress,
boolean retry)
Simple ServerSocket creator method. |
abstract java.net.ServerSocket |
createServerSocket(int port,
int backlog,
java.net.InetAddress addr)
Simple ServerSocket creator method. |
abstract java.net.Socket |
createSocket(java.net.InetAddress rAddr,
int rPort)
Simple client Socket creator method. |
abstract java.net.Socket |
createSocket(java.net.InetAddress dest,
int port,
java.net.InetAddress localIP,
long timeoutMillis)
client Socket creator method with a timeout. |
void |
shutdown()
Hook for shutdown of socket factory. |
static void |
tuneSocket(java.net.Socket s)
Configures a socket according to user-specified properties. |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
public abstract java.net.ServerSocket createServerSocket(int port, int backlog, java.net.InetAddress addr) throws java.io.IOException
port
- the local TCP portbacklog
- the listen backlogaddr
- the local Inetaddress the server will bind to
java.io.IOException
- when the socket could not be created for some
reason.public abstract java.net.Socket createSocket(java.net.InetAddress rAddr, int rPort) throws java.io.IOException
rAddr
- the IP addressrPort
- the port
java.io.IOException
- when the socket could not be created for some
reason.public int allocLocalPort()
ibis.port.range
can be used to specify a
port range, for instance 3000-4000. This can be used to choose port
numbers that are for instance not protected by a firewall.
If such a range is not given, 0 is returned.
public abstract java.net.Socket createSocket(java.net.InetAddress dest, int port, java.net.InetAddress localIP, long timeoutMillis) throws java.io.IOException
localIP
address is null
, this method tries to
bind to the first of this machine's IP addresses. Otherwise, it uses the
specified address.
dest
- the IP addressport
- the portlocalIP
- the local IP address, or null
timeoutMillis
- if < 0, throw exception on failure.
If 0, retry until success.
if > 0, block at most timeoutMillis
milliseconds.
java.io.IOException
- is thrown when the socket was not properly created
within this time.public abstract java.net.ServerSocket createServerSocket(int port, java.net.InetAddress localAddress, boolean retry) throws java.io.IOException
null
,
the first of this machine's IP addresses is chosen.
port
- the local TCP port, or 0, in which case a free port is
chosen.localAddress
- the local Inetaddress the server will bind to, or
null
.retry
- when true
, the method blocks until the socket
is successfuly created.
java.io.IOException
- when the socket could not be created for some
reason.public java.net.Socket accept(java.net.ServerSocket a) throws java.io.IOException
a
- the server socket
java.io.IOException
- is thrown when the accept fails for some reason.public java.net.Socket createBrokeredSocket(java.net.Socket s, boolean isServer, ibis.connect.socketFactory.ConnectionPropertiesProvider p) throws java.io.IOException
s
- socket to negotiate onisServer
- must be set to true on one side, false on the other.p
- connection properties, can be used to pass on socket-dependent
parameters.
java.io.IOException
- is thrown when the socket could not
be created for some reason.public java.net.Socket createBrokeredSocket(java.io.InputStream in, java.io.OutputStream out, boolean isServer, ibis.connect.socketFactory.ConnectionPropertiesProvider p) throws java.io.IOException
in
- input streamout
- output streamisServer
- must be set to true on one side, false on the other.p
- connection properties, can be used to pass on socket-dependent
parameters.
java.io.IOException
- is thrown when the socket could not
be created for some reason.public void close(java.io.InputStream in, java.io.OutputStream out, java.net.Socket s)
in
- the inputstream ot be closedout
- the outputstream to be closeds
- the socket to be closedpublic void shutdown()
public static IbisSocketFactory createFactory()
IbisSocketFactory
.
An implementation can be chosen by means of the
ibis.socketfactory
system property. If not set,
a default implementation is chosen.
null
if it
could not be found.public static void tuneSocket(java.net.Socket s) throws java.io.IOException
s
- the socket to be configured
java.io.IOException
- when configuring fails for some reason.
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |