Class SCPConnection
java.lang.Object
uk.ac.manchester.spinnaker.connections.UDPConnection<SDPMessage>
uk.ac.manchester.spinnaker.connections.SDPConnection
uk.ac.manchester.spinnaker.connections.SCPConnection
- All Implemented Interfaces:
Closeable,AutoCloseable,Connection,SCPSenderReceiver
- Direct Known Subclasses:
DelegatingSCPConnection
An SDP connection to talk SCP (SpiNNaker Control Protocol) to SC&MP on a
SpiNNaker system, and to the cores managed by it. In general, an
SCPConnection is thread safe when used via a TxrxProcess, but
not all operations that can be invoked that way are;
flood-fills of binaries are particularly known to
be only safe to do strictly one at a time and with no other traffic.-
Nested Class Summary
Nested classes/interfaces inherited from class uk.ac.manchester.spinnaker.connections.UDPConnection
UDPConnection.TrafficClass -
Constructor Summary
ConstructorsModifierConstructorDescriptionSCPConnection(HasChipLocation chip, InetAddress localHost, Integer localPort, InetAddress remoteHost) Create a connection to a particular instance of SCAMP.protectedSCPConnection(HasChipLocation chip, InetAddress localHost, Integer localPort, InetAddress remoteHost, int remotePort) Create a connection to a particular instance of SCAMP. -
Method Summary
Modifier and TypeMethodDescriptionprotected final voidClose this connection, logging failures instead of throwing.voidClose this connection eventually.final SCPResultMessagereceiveSCPResponse(int timeout) Receives an SCP response from this connection.voidsend(ByteBuffer requestData, int seq) Send a request that expects a response to be appropriately directed to the thread that is calling this method.toString()Methods inherited from class uk.ac.manchester.spinnaker.connections.SDPConnection
getChip, receiveMessage, send, setChipMethods inherited from class uk.ac.manchester.spinnaker.connections.UDPConnection
close, doReceive, doReceiveWithAddress, doSend, doSendTo, getLocalAddress, getLocalIPAddress, getLocalPort, getRemoteAddress, getRemoteIPAddress, getRemotePort, isClosed, isConnected, 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, isClosed, isConnected, receive, receiveWithAddress, send, sendToMethods inherited from interface uk.ac.manchester.spinnaker.connections.model.SCPSenderReceiver
getChip, getSCPData, receiveSCPResponse, send
-
Constructor Details
-
SCPConnection
public SCPConnection(HasChipLocation chip, InetAddress localHost, Integer localPort, InetAddress remoteHost) throws IOException Create a connection to a particular instance of SCAMP.- Parameters:
chip- The location of the chip on the board with this remoteHostlocalHost- The optional host of the local interface to listen on; usenullto listen on all local interfaces.localPort- The optional local port to listen on; usenullto pick a random port.remoteHost- The remote host to send messages to.- Throws:
IOException- If anything goes wrong with socket setup.
-
SCPConnection
protected SCPConnection(HasChipLocation chip, InetAddress localHost, Integer localPort, InetAddress remoteHost, int remotePort) throws IOException Create a connection to a particular instance of SCAMP. Can use a specified local network interface.- Parameters:
chip- The location of the chip on the board with this remoteHostlocalHost- The optional host of the local interface to listen on; usenullto listen on all local interfaces.localPort- The optional local port to listen on; usenullto pick a random port.remoteHost- The remote host to send messages to.remotePort- The optional remote port number to send messages to. Ifnull, the default remote port is used.- Throws:
IOException- If anything goes wrong with socket setup.
-
-
Method Details
-
receiveSCPResponse
public final SCPResultMessage receiveSCPResponse(int timeout) throws IOException, InterruptedException Receives an SCP response from this connection. Blocks until a message has been received, or a timeout occurs.This is tricky code because there can be multiple threads using a connection at once and we need to direct responses to the threads that originated the requests that the responses match to. A consequence of this is that it is possible for the wait for a message to be longer than the timeout given; that will occur when the current thread keeps receiving messages for other threads.
- Specified by:
receiveSCPResponsein interfaceSCPSenderReceiver- Parameters:
timeout- The time in milliseconds to wait for the message to arrive, or until the connection is closed.- Returns:
- The SCP result, the sequence number, and the data of the response. The buffer pointer will be positioned at the point where the payload starts.
- Throws:
IOException- If there is an error receiving the messageSocketTimeoutException- If there is a timeout before a message is receivedInterruptedException- If communications are interrupted.
-
closeEventually
public void closeEventually()Close this connection eventually. The close might not happen immediately. -
closeAndLogNoExcept
protected final void closeAndLogNoExcept()Close this connection, logging failures instead of throwing.Core of implementation of
closeEventually(). -
send
Description copied from interface:SCPSenderReceiverSend a request that expects a response to be appropriately directed to the thread that is calling this method.- Specified by:
sendin interfaceSCPSenderReceiver- Parameters:
requestData- The message data to send.seq- The sequence number to come in the response.- Throws:
IOException- If there is an error sending the message- See Also:
-
toString
- Overrides:
toStringin classUDPConnection<SDPMessage>
-