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.

  • 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, or null to bind to all relevant local addresses.
      localPort - The local port to bind to, or null 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

      public void send(SDPMessage sdpMessage) throws IOException
      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, InterruptedException
      Description 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 class UDPConnection<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 message
      InterruptedException - If communications are interrupted.
      InterruptedIOException
    • getChip

      public ChipLocation getChip()
      Returns:
      The SpiNNaker chip that we are talking to with this connection.
    • setChip

      public void setChip(HasChipLocation chip)
      Set the SpiNNaker chip that we are talking to with this connection.
      Parameters:
      chip - The chip to talk to.