Modifier and Type | Field and Description |
---|---|
private java.net.InetSocketAddress |
address |
static int |
DEFAULT_PORT |
private static long |
DELAY_BETWEEN_SOCKET_CHECKS |
private static java.net.InetSocketAddress |
localhost |
private java.net.Socket |
lockSocket |
private static java.lang.Object |
syncObject |
Constructor and Description |
---|
SocketLock()
Constructs a new SocketLock using the default port.
|
SocketLock(java.net.InetSocketAddress address)
Constructs a new SocketLock.
|
SocketLock(int lockPort)
Constructs a new SocketLock.
|
Modifier and Type | Method and Description |
---|---|
void |
close() |
int |
getLockPort()
Gets the port number that is being-locked.
|
private boolean |
isLockFree(java.net.InetSocketAddress address)
Test to see if the lock is free.
|
void |
lock(long timeoutInMillis) |
void |
unlock() |
public static final int DEFAULT_PORT
private static final long DELAY_BETWEEN_SOCKET_CHECKS
private static java.lang.Object syncObject
private static final java.net.InetSocketAddress localhost
private final java.net.Socket lockSocket
private final java.net.InetSocketAddress address
public SocketLock()
public SocketLock(int lockPort)
lockPort
- the port number to lockpublic SocketLock(java.net.InetSocketAddress address)
address
- The port to lock.public void lock(long timeoutInMillis) throws WebDriverException
lock
in interface Lock
WebDriverException
public void close() throws java.io.IOException
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
java.io.IOException
private boolean isLockFree(java.net.InetSocketAddress address) throws java.io.IOException
address
- the address to attempt to bind tojava.io.IOException
- if something goes catastrophically wrong with the socketpublic int getLockPort()