com.objectwave.networkUtility
Class UDPUtils

java.lang.Object
  |
  +--com.objectwave.networkUtility.UDPUtils

public class UDPUtils
extends java.lang.Object

UDP is commonly used for broadcast capabilities. By sending to the highest ip of a network address, all subnet members will receive the UDP packet. A network address is the IP address of a machines bit wised anded with the network mask. example: 206.20.164.18 is my machine's IP. 255.255.255.0 is my subnet mask. 206.20.164.0 is our network address. 206.20.164.255 is the standard broadcast address. However, it may be better to use a multicast socket instead.

Version:
$Id: UDPUtils.java,v 2.0 2001/06/11 15:54:25 dave_hoag Exp $
Author:
dhoag

Constructor Summary
UDPUtils()
           
 
Method Summary
 void close()
           
 java.lang.Object receiveObjectUDP(int portNumber)
          Retrieve an object on the specified port number.
static byte[] receiveUDP(int numBytes, int portNumber)
          Receive a UDP packet from a local UDP port, as an array of bytes.
 void sendObjectUDP(java.lang.Object o, java.lang.String host, int portNumber)
           
static void sendUDP(byte[] msg, java.lang.String host, int portNumber)
          Send a byte array as a UDP packet to some host & port.
static void setVerbose(boolean state)
          Sets the Verbose attribute of the UDPUtils class
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UDPUtils

public UDPUtils()
Method Detail

setVerbose

public static void setVerbose(boolean state)
Sets the Verbose attribute of the UDPUtils class

Parameters:
state - The new Verbose value

receiveUDP

public static byte[] receiveUDP(int numBytes,
                                int portNumber)
                         throws java.net.SocketException,
                                java.io.IOException
Receive a UDP packet from a local UDP port, as an array of bytes.

Parameters:
numBytes -
portNumber -
Returns:
Throws:
java.net.SocketException
java.io.IOException

sendUDP

public static void sendUDP(byte[] msg,
                           java.lang.String host,
                           int portNumber)
                    throws java.net.SocketException,
                           java.io.IOException,
                           java.net.UnknownHostException
Send a byte array as a UDP packet to some host & port.

Parameters:
msg -
host -
portNumber -
Throws:
java.net.SocketException
java.io.IOException
java.net.UnknownHostException

close

public void close()

receiveObjectUDP

public java.lang.Object receiveObjectUDP(int portNumber)
Retrieve an object on the specified port number.

Parameters:
portNumber -
Returns:

sendObjectUDP

public void sendObjectUDP(java.lang.Object o,
                          java.lang.String host,
                          int portNumber)
Parameters:
o -
host -
portNumber -