Class SDPConnection
java.lang.Object
uk.ac.manchester.spinnaker.connections.UDPConnection<SDPMessage>
uk.ac.manchester.spinnaker.connections.SDPConnection
- All Implemented Interfaces:
Closeable
,AutoCloseable
,Connection
- Direct Known Subclasses:
SCPConnection
public class SDPConnection extends UDPConnection<SDPMessage>
A UDP socket connection that talks SDP (SpiNNaker Datagram Protocol) to
SpiNNaker. An inbound SDP packet can be routed from the initially receiving
SC&MP core to any core, and an outbound SDP packet can be routed from any
core to the outside world (provided an
IPTag
or ReverseIPTag
is configured to handle routing of the message on an Ethernet-equipped chip).
Note that, unlike with an SCPConnection
, SDP is essentially a
collection of one-way messages, though replies might be expected to some of
them. As such, this class makes no attempt to handle demultiplexing of
messages received on multiple threads; great care must be taken when using
this class from more than one thread at a time.
-
Nested Class Summary
Nested classes/interfaces inherited from class uk.ac.manchester.spinnaker.connections.UDPConnection
UDPConnection.TrafficClass
-
Constructor Summary
Constructors Constructor Description SDPConnection(HasChipLocation remoteChip, InetAddress localHost, Integer localPort, InetAddress remoteHost, Integer remotePort)
-
Method Summary
Modifier and Type Method Description ChipLocation
getChip()
SDPMessage
receiveMessage(int timeout)
Receives a SpiNNaker message from this connection.void
send(SDPMessage sdpMessage)
Sends an SDP message down this connection.void
setChip(HasChipLocation chip)
Set the SpiNNaker chip that we are talking to with this connection.Methods 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, setReceivePacketSize, toString
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface uk.ac.manchester.spinnaker.connections.model.Connection
convertTimeout
-
Constructor Details
-
SDPConnection
public SDPConnection(HasChipLocation remoteChip, InetAddress localHost, Integer localPort, InetAddress remoteHost, Integer remotePort) throws IOException- Parameters:
remoteChip
- Which chip are we talking to? This is not necessarily the chip that is connected to the Ethernet connector on the SpiNNaker board, or even on the same board.localHost
- The local host address to bind to, ornull
to bind to all relevant local addresses.localPort
- The local port to bind to, ornull
to pick a random free port.remoteHost
- The address of the SpiNNaker board to route UDP packets to.remotePort
- The UDP port on the SpiNNaker board to use.- Throws:
IOException
- If anything goes wrong with the setup (e.g., if the local port is specified and already bound).
-
-
Method Details
-
send
Sends an SDP message down this connection.- Parameters:
sdpMessage
- The SDP message to be sent- Throws:
IOException
- If there is an error sending the message.
-
receiveMessage
public SDPMessage receiveMessage(int timeout) throws IOException, InterruptedIOException, InterruptedExceptionDescription copied from class:UDPConnection
Receives a SpiNNaker message from this connection. Blocks until a message has been received, or a timeout occurs.- Specified by:
receiveMessage
in classUDPConnection<SDPMessage>
- Parameters:
timeout
- The time in seconds to wait for the message to arrive, or until the connection is closed.- Returns:
- the received message
- Throws:
IOException
- If there is an error receiving the messageSocketTimeoutException
- If there is a timeout during receivingInterruptedException
- If communications are interrupted.InterruptedIOException
-
getChip
- Returns:
- The SpiNNaker chip that we are talking to with this connection.
-
setChip
Set the SpiNNaker chip that we are talking to with this connection.- Parameters:
chip
- The chip to talk to.
-