|
LimeWire Consolidated API | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
public interface SocketsManager
Factory for creating Sockets.
| Nested Class Summary | |
|---|---|
static class |
SocketsManager.ConnectType
The different ways a connection can be attempted. |
| Method Summary | ||
|---|---|---|
boolean |
canConnect(Address address)
Returns true if there is a connector that can connect to the address. |
|
boolean |
canResolve(Address address)
Returns true if there is a resolver that can resolve the address. |
|
|
connect(Address address,
T observer)
Asynchronously connects to address resolving the address if
possible/necessary and notifying observer of the success or
failure. |
|
Socket |
connect(InetSocketAddress addr,
int timeout)
Connects and returns a socket to the given host, with a timeout. |
|
Socket |
connect(InetSocketAddress addr,
int timeout,
ConnectObserver observer)
Sets up a socket for connecting. |
|
Socket |
connect(InetSocketAddress addr,
int timeout,
ConnectObserver observer,
SocketsManager.ConnectType type)
Sets up a socket for connecting. |
|
Socket |
connect(InetSocketAddress addr,
int timeout,
SocketsManager.ConnectType type)
Connects and returns a socket to the given host, with a timeout. |
|
Socket |
connect(NBSocket socket,
InetSocketAddress localAddr,
InetSocketAddress remoteAddr,
int timeout,
ConnectObserver observer,
SocketsManager.ConnectType type)
Connects and returns a socket to the given host, with a timeout. |
|
Socket |
connect(NBSocket socket,
InetSocketAddress localAddr,
InetSocketAddress remoteAddr,
int timeout,
SocketsManager.ConnectType type)
Connects and returns a socket to the given host, with a timeout. |
|
Socket |
create(SocketsManager.ConnectType type)
Creates a new Socket |
|
int |
getNumAllowedSockets()
Returns the number of Sockets allowed to be created concurrently. |
|
int |
getNumWaitingSockets()
Returns the number of Sockets that are waiting for the controller to process them. |
|
void |
registerConnector(AddressConnector connector)
Registers an AddressConnector to handle connects for certain types
of address. |
|
void |
registerResolver(AddressResolver resolver)
Registers an AddressResolver to handle address resolution for
certain types of addresses. |
|
boolean |
removeConnectObserver(ConnectObserver observer)
Removes the given ConnectObserver from wanting to make a request. |
|
|
resolve(Address address,
T observer)
Asynchronously resolves address to other addresses if
possible and notifying observer of the success or
failure. |
|
| Methods inherited from interface org.limewire.listener.ListenerSupport |
|---|
addListener, removeListener |
| Method Detail |
|---|
Socket create(SocketsManager.ConnectType type)
throws IOException
Socket. Does NOT bind or connnect the Socket
The creation will use the specified connection type.
For example, to make a plain socket, use ConnectType.PLAIN.
To connect with a TLS Socket, use ConnectType.TLS.
- Parameters:
type - the type of Socket to create
- Returns:
-
- Throws:
IOException
Socket connect(NBSocket socket,
InetSocketAddress localAddr,
InetSocketAddress remoteAddr,
int timeout,
SocketsManager.ConnectType type)
throws IOException
socket - the socket to connect; if null a new Socket will be createdlocalAddr - the Socket address to bind to locally; can be nullremoteAddr - the host/port to connect totimeout - the desired timeout for connecting, in milliseconds,
or 0 for no timeout. In case of a proxy connection, this timeout
might be exceededtype - the type of connection to attempt
IOException - the connections couldn't be made in the
requested time
IllegalArgumentException - if the port is invalid
Socket connect(NBSocket socket,
InetSocketAddress localAddr,
InetSocketAddress remoteAddr,
int timeout,
ConnectObserver observer,
SocketsManager.ConnectType type)
throws IOException
socket - the socket to connect; if null a new Socket will be createdlocalAddr - the Socket address to bind to locally; can be nullremoteAddr - the host/port to connect totimeout - the desired timeout for connecting, in milliseconds,
or 0 for no timeout. In case of a proxy connection, this timeout
might be exceededtype - the type of connection to attempt
IOException - the connections couldn't be made in the
requested time
IllegalArgumentException - if the port is invalid
Socket connect(InetSocketAddress addr,
int timeout)
throws IOException
addr - the host/port to connect totimeout - the desired timeout for connecting, in milliseconds,
or 0 for no timeout. In case of a proxy connection, this timeout
might be exceeded
IOException - the connections couldn't be made in the
requested time
IllegalArgumentException - if the port is invalid
Socket connect(InetSocketAddress addr,
int timeout,
SocketsManager.ConnectType type)
throws IOException
addr - the host/port to connect totimeout - the desired timeout for connecting, in milliseconds,
or 0 for no timeout. In case of a proxy connection, this timeout
might be exceededtype - the type of connection to attempt
IOException - the connections couldn't be made in the
requested time
IllegalArgumentException - if the port is invalid
Socket connect(InetSocketAddress addr,
int timeout,
ConnectObserver observer)
throws IOException
addr - address/porttimeout - the desired timeout for connecting, in milliseconds,
or 0 for no timeout. In case of a proxy connection, this timeout
might be exceededobserver - the ConnectObserver to notify about non-blocking connect events
IOException - see above
IllegalArgumentException - if the port is invalid
Socket connect(InetSocketAddress addr,
int timeout,
ConnectObserver observer,
SocketsManager.ConnectType type)
throws IOException
addr - address/porttimeout - the desired timeout for connecting, in milliseconds,
or 0 for no timeout. In case of a proxy connection, this timeout
might be exceededobserver - the ConnectObserver to notify about non-blocking connect eventstype - the type of connection to attempt
IOException - see above
IllegalArgumentException - if the port is invalid
<T extends ConnectObserver> T connect(Address address,
T observer)
address resolving the address if
possible/necessary and notifying observer of the success or
failure.
timeout - timeout in milliseconds
<T extends AddressResolutionObserver> T resolve(Address address,
T observer)
address to other addresses if
possible and notifying observer of the success or
failure.
If there is no resolver for address, the observer is notified of a address resolution with the exact same address.
boolean removeConnectObserver(ConnectObserver observer)
int getNumAllowedSockets()
int getNumWaitingSockets()
void registerConnector(AddressConnector connector)
AddressConnector to handle connects for certain types
of address.
When #connect(Address, int, ConnectObserver) is called the sockets
manager will iterate over all registered address connectors
and see which one can connect to the given address.
See AddressConnector.
void registerResolver(AddressResolver resolver)
AddressResolver to handle address resolution for
certain types of addresses.
When #resolve(Address, int, AddressResolutionObserver) is called the sockets
manager will iterate over all registered address resolvers
and see which one can resolve the given address.
See AddressResolver.
boolean canConnect(Address address)
boolean canResolve(Address address)
|
LimeWire Consolidated API | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||