Class NotificationConnection

java.lang.Object
uk.ac.manchester.spinnaker.connections.UDPConnection<NotificationMessage>
uk.ac.manchester.spinnaker.connections.NotificationConnection
All Implemented Interfaces:
Closeable, AutoCloseable, Connection

public class NotificationConnection extends UDPConnection<NotificationMessage>
A UDP connection for sending and receiving notification protocol messages. These messages go between programs on host; they do not go to and from SpiNNaker and are not constrained by SpiNNaker's message size rules.
  • Constructor Details

    • NotificationConnection

      public NotificationConnection(InetAddress localHost) throws IOException
      Create a notification protocol connection only available for listening, using default local port.
      Parameters:
      localHost - The local IP address to bind to.
      Throws:
      IOException - If there is an error setting up the communication channel
    • NotificationConnection

      public NotificationConnection(InetAddress localHost, Integer localPort) throws IOException
      Create a notification protocol connection only available for listening.
      Parameters:
      localHost - The local IP address to bind to.
      localPort - The local port to bind to, 0 or between 1025 and 65535.
      Throws:
      IOException - If there is an error setting up the communication channel
    • NotificationConnection

      public NotificationConnection(InetAddress localHost, Integer localPort, InetAddress remoteHost, Integer remotePort) throws IOException
      Create a notification protocol connection that is bound to a particular remote location (where the toolchain should be running).
      Parameters:
      localHost - The local host to bind to. If not specified, it defaults to binding to all interfaces, unless remoteHost is specified, in which case binding is done to the IP address that will be used to send packets.
      localPort - The local port to bind to, 0 or between 1025 and 65535.
      remoteHost - The remote host to send packets to. If not specified, the socket will be available for listening only, and will throw and exception if used for sending.
      remotePort - The remote port to send packets to. If remoteHost is null, this is ignored. If remoteHost is specified, this must also be specified as non-zero for the connection to allow sending.
      Throws:
      IOException - If there is an error setting up the communication channel
  • Method Details

    • sendNotification

      public void sendNotification(NotificationMessage notificationMessage) throws IOException
      Sends a notification message down this connection.
      Parameters:
      notificationMessage - The notification message to be sent
      Throws:
      IOException - If there is an error sending the message
    • receiveMessage

      public NotificationMessage receiveMessage(int timeout) throws IOException, 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<NotificationMessage>
      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.