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.
-
Nested Class Summary
Nested classes/interfaces inherited from class uk.ac.manchester.spinnaker.connections.UDPConnection
UDPConnection.TrafficClass
-
Constructor Summary
Constructors Constructor Description NotificationConnection(InetAddress localHost)
Create a notification protocol connection only available for listening, using default local port.NotificationConnection(InetAddress localHost, Integer localPort)
Create a notification protocol connection only available for listening.NotificationConnection(InetAddress localHost, Integer localPort, InetAddress remoteHost, Integer remotePort)
Create a notification protocol connection that is bound to a particular remote location (where the toolchain should be running). -
Method Summary
Modifier and Type Method Description NotificationMessage
receiveMessage(int timeout)
Receives a SpiNNaker message from this connection.void
sendNotification(NotificationMessage notificationMessage)
Sends a notification message down 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
-
NotificationConnection
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
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 IOExceptionCreate 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, unlessremoteHost
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 isnull
, 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
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
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 classUDPConnection<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 messageSocketTimeoutException
- If there is a timeout during receivingInterruptedException
- If communications are interrupted.
-