Class DelegatingSCPConnection
java.lang.Object
uk.ac.manchester.spinnaker.connections.UDPConnection<SDPMessage>
uk.ac.manchester.spinnaker.connections.SDPConnection
uk.ac.manchester.spinnaker.connections.SCPConnection
uk.ac.manchester.spinnaker.connections.DelegatingSCPConnection
- All Implemented Interfaces:
Closeable,AutoCloseable,Connection,SCPSenderReceiver
An SCP connection that actually delegates message sending and receiving to
another connection. Note that closing a delegating connection does nothing;
the socket is only closed when the real underlying connection is closed.
- Author:
- Donal Fellows
-
Nested Class Summary
Nested classes/interfaces inherited from class uk.ac.manchester.spinnaker.connections.UDPConnection
UDPConnection.TrafficClass -
Constructor Summary
ConstructorsConstructorDescriptionDelegatingSCPConnection(SDPConnection connection) Create a connection that delegates actual communications to another connection. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()When we're delegating, closing is a no-op; the underlying channel has to be closed directly.protected ByteBufferdoReceive(int timeout) Receive data from the connection.protected UDPPacketdoReceiveWithAddress(int timeout) Receive data from the connection along with the address where the data was received from.protected voiddoSend(ByteBuffer data) Send data down this connection.protected voiddoSendTo(ByteBuffer data, InetAddress address, int port) Send data down this connection.protected InetSocketAddressGet the local socket address.protected InetSocketAddressGet the remote socket address.booleanisClosed()Determines if the medium is closed at this point in time.booleanDetermines if the medium is connected at this point in time.toString()Methods inherited from class uk.ac.manchester.spinnaker.connections.SCPConnection
closeAndLogNoExcept, closeEventually, receiveSCPResponse, sendMethods inherited from class uk.ac.manchester.spinnaker.connections.SDPConnection
getChip, receiveMessage, send, setChipMethods inherited from class uk.ac.manchester.spinnaker.connections.UDPConnection
getLocalIPAddress, getLocalPort, getRemoteIPAddress, getRemotePort, receive, receive, receiveMessage, receiveWithAddress, send, send, sendPortTriggerMessage, sendTo, sendTo, sendTo, setInUse, setNotInUse, setReceivePacketSizeMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface uk.ac.manchester.spinnaker.connections.model.Connection
convertTimeout, getLocalIPAddress, getLocalPort, getRemoteIPAddress, getRemotePort, receive, receiveWithAddress, send, sendToMethods inherited from interface uk.ac.manchester.spinnaker.connections.model.SCPSenderReceiver
getChip, getSCPData, receiveSCPResponse, send
-
Constructor Details
-
DelegatingSCPConnection
Create a connection that delegates actual communications to another connection.- Parameters:
connection- The connection to delegate to.- Throws:
IOException- If anything goes wrong. (Unexpected)
-
-
Method Details
-
getLocalAddress
Description copied from class:UDPConnectionGet the local socket address. (Sockets have two ends, one local, one remote.)This operation is delegatable; see
DelegatingSCPConnection.- Overrides:
getLocalAddressin classUDPConnection<SDPMessage>- Returns:
- The socket's local address
- Throws:
IOException- If the socket is closed.
-
getRemoteAddress
Description copied from class:UDPConnectionGet the remote socket address. (Sockets have two ends, one local, one remote.)This operation is delegatable; see
DelegatingSCPConnection.- Overrides:
getRemoteAddressin classUDPConnection<SDPMessage>- Returns:
- The socket's remote address
-
doReceive
protected ByteBuffer doReceive(int timeout) throws SocketTimeoutException, IOException, InterruptedException Description copied from class:UDPConnectionReceive data from the connection.This operation is delegatable; see
DelegatingSCPConnection.- Overrides:
doReceivein classUDPConnection<SDPMessage>- Parameters:
timeout- The timeout in milliseconds- Returns:
- The data received, in a little-endian buffer
- Throws:
SocketTimeoutException- If a timeout occurs before any data is receivedIOException- If an error occurs receiving the dataInterruptedException- If communications are interrupted.
-
doReceiveWithAddress
Description copied from class:UDPConnectionReceive data from the connection along with the address where the data was received from.This operation is delegatable; see
DelegatingSCPConnection.- Overrides:
doReceiveWithAddressin classUDPConnection<SDPMessage>- Parameters:
timeout- The timeout in milliseconds- Returns:
- The datagram packet received
- Throws:
SocketTimeoutException- If a timeout occurs before any data is receivedIOException- If an error occurs receiving the data
-
doSend
Description copied from class:UDPConnectionSend data down this connection.This operation is delegatable; see
DelegatingSCPConnection.- Overrides:
doSendin classUDPConnection<SDPMessage>- Parameters:
data- The data to be sent; the position in this buffer will not be updated by this method- Throws:
IOException- If there is an error sending the data
-
doSendTo
Description copied from class:UDPConnectionSend data down this connection.This operation is delegatable; see
DelegatingSCPConnection.- Overrides:
doSendToin classUDPConnection<SDPMessage>- Parameters:
data- The data to be sentaddress- Where to send (must be non-null)port- What port to send to (must be non-zero)- Throws:
IOException- If there is an error sending the data
-
isConnected
public boolean isConnected()Description copied from interface:ConnectionDetermines if the medium is connected at this point in time. Connected media are not closed. Disconnected media might not be open.- Specified by:
isConnectedin interfaceConnection- Overrides:
isConnectedin classUDPConnection<SDPMessage>- Returns:
- true if the medium is connected, false otherwise
-
isClosed
public boolean isClosed()Description copied from interface:ConnectionDetermines if the medium is closed at this point in time. Closed media are not connected. Open media might not be connected.- Specified by:
isClosedin interfaceConnection- Overrides:
isClosedin classUDPConnection<SDPMessage>- Returns:
- true if the medium is closed, false otherwise
-
close
When we're delegating, closing is a no-op; the underlying channel has to be closed directly.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classUDPConnection<SDPMessage>- Throws:
IOException
-
toString
- Overrides:
toStringin classSCPConnection
-