hp.infrared
Class UltraSocket

java.lang.Object
  |
  +--hp.infrared.UltraSocket

public class UltraSocket
extends java.lang.Object

This class implements a connectionless broadcast socket using Ultra protocol.

See Also:
UltraPacket

Constructor Summary
UltraSocket(int pid)
          Constructs an ultra socket with the specified protocol id
 
Method Summary
 void close()
          Closes this ultra socket.
 void receive(UltraPacket pkt)
          Receives an ultra packet from this socket.
 void send(UltraPacket pkt)
          Sends an ultra packet from this socket.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UltraSocket

public UltraSocket(int pid)
            throws java.net.SocketException
Constructs an ultra socket with the specified protocol id
Parameters:
pid - the ultra protocol id
Throws:
java.net.SocketException - if I/O error occurs
Method Detail

close

public void close()
Closes this ultra socket.

receive

public void receive(UltraPacket pkt)
             throws java.io.IOException
Receives an ultra packet from this socket. When this method returns, the UltraPacket's buffer is filled with the data received. This method blocks until a packet is received. The length field of the ultra packet object contains the length of the received message. If the message is longer than the buffer length, the message is truncated.
Parameters:
pkt - the packet received
Throws:
java.io.IOException - if any I/O error occurs

send

public void send(UltraPacket pkt)
          throws java.io.IOException
Sends an ultra packet from this socket. The UltraPacket includes information indicating the data to be sent and its length.
Parameters:
pkt - the ultra packet
Throws:
java.io.IOException - if an I/O error occurs