Class EIEIOConnection
java.lang.Object
uk.ac.manchester.spinnaker.connections.UDPConnection<EIEIOMessage<? extends EIEIOHeader>>
uk.ac.manchester.spinnaker.connections.EIEIOConnection
- All Implemented Interfaces:
Closeable
,AutoCloseable
,Connection
public class EIEIOConnection extends UDPConnection<EIEIOMessage<? extends EIEIOHeader>>
A UDP connection for sending and receiving raw EIEIO messages.
-
Nested Class Summary
Nested classes/interfaces inherited from class uk.ac.manchester.spinnaker.connections.UDPConnection
UDPConnection.TrafficClass
-
Constructor Summary
Constructors Constructor Description EIEIOConnection(InetAddress localHost, Integer localPort)
Create an EIEIO connection only available for listening. -
Method Summary
Modifier and Type Method Description protected EIEIOCommand
receiveCommand()
Receive a raw command.EIEIOMessage<? extends EIEIOHeader>
receiveMessage(int timeout)
Receives a SpiNNaker message from this connection.protected void
sendCommand(int command)
Send a raw command.protected void
sendCommand(EIEIOCommand command)
Send a raw command.protected void
sendCommand(EIEIOCommand command, InetAddress ipAddress, int port)
Send a raw command.void
sendEIEIOMessage(EIEIOMessage<?> eieioMessage)
Sends an EIEIO message down this connection.void
sendEIEIOMessageTo(EIEIOMessage<? extends EIEIOHeader> eieioMessage, InetAddress ipAddress, int port)
Send an EIEIO message to a specific destination.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
-
EIEIOConnection
Create an EIEIO connection only available for listening.- Parameters:
localHost
- The local IP address 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.- Throws:
IOException
- If there is an error setting up the communication channel
-
-
Method Details
-
sendEIEIOMessage
Sends an EIEIO message down this connection.- Parameters:
eieioMessage
- The EIEIO message to be sent- Throws:
IOException
- If there is an error sending the message
-
sendCommand
Send a raw command.- Parameters:
command
- The command to send.- Throws:
IOException
- If sending fails.
-
sendCommand
Send a raw command.- Parameters:
command
- The command to send.- Throws:
IOException
- If sending fails.
-
sendCommand
protected void sendCommand(EIEIOCommand command, InetAddress ipAddress, int port) throws IOExceptionSend a raw command.- Parameters:
command
- The command to send.ipAddress
- The host to send to.port
- The port to send to.- Throws:
IOException
- If sending fails.
-
receiveCommand
Receive a raw command.- Returns:
- the command ID
- Throws:
IOException
- If receiving fails.InterruptedException
- If communications are interrupted.
-
sendEIEIOMessageTo
public void sendEIEIOMessageTo(EIEIOMessage<? extends EIEIOHeader> eieioMessage, InetAddress ipAddress, int port) throws IOExceptionSend an EIEIO message to a specific destination.- Parameters:
eieioMessage
- The message to send.ipAddress
- The host to send to.port
- The port to send to.- Throws:
IOException
- If anything goes wrong in sending.
-
receiveMessage
public EIEIOMessage<? extends EIEIOHeader> receiveMessage(int timeout) throws IOException, 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<EIEIOMessage<? extends EIEIOHeader>>
- 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.
-