public class SRPSocket
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static SRPPacketDecorator |
DECO |
Constructor and Description |
---|
SRPSocket(java.net.Inet4Address remoteAddr,
int remotePort)
Create an SRP socket to the given remote address.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes the socket
|
protected void |
finalize() |
SRPSocketCallback |
getCallback()
Gets the SRP callback.
|
java.net.Inet4Address |
getLocalAddress() |
java.net.Inet4Address |
getRemoteAddress() |
boolean |
isBroadcast()
Returns whether or not this is a broadcasting socket.
|
java.net.SocketAddress |
localAddress() |
byte[] |
receive()
Receives data.
|
boolean |
receivePending()
Returns whether there is anything to receive.
|
java.net.SocketAddress |
remoteAddress() |
void |
send(byte[] data)
Send data onto the network.
|
void |
setCallback(SRPSocketCallback callback)
Sets the SRP Callback.
|
int |
transactionCount()
Returns the number of active transactions.
|
public static SRPPacketDecorator DECO
public SRPSocket(java.net.Inet4Address remoteAddr, int remotePort) throws java.io.IOException
remoteAddr
- The remote address to send to, or broadcast address.remotePort
- The remote port to send to.mgr
- The SRPSocketManager to use.java.io.IOException
- When the socket could not be created.public void setCallback(SRPSocketCallback callback)
callback
- The callback.public SRPSocketCallback getCallback()
public java.net.Inet4Address getRemoteAddress()
public java.net.Inet4Address getLocalAddress()
public boolean isBroadcast()
true
if it is in broadcast mode, false
if it is in unicast mode.public void send(byte[] data) throws java.io.IOException
data
- The data to send.java.io.IOException
- If the socket was closed unexpectedly.public boolean receivePending()
true
if it is data to receive, false
if there is not.public byte[] receive()
null
if there is nothing to receive, otherwise an array of data.public void close() throws java.lang.InterruptedException
java.lang.InterruptedException
- When the closing process was interrupted.public java.net.SocketAddress remoteAddress()
public java.net.SocketAddress localAddress()
public int transactionCount()
protected void finalize() throws java.lang.Throwable
finalize
in class java.lang.Object
java.lang.Throwable