--- projects/cms/source/host/java/LowLevelNet.java 2000/11/27 19:44:50 1.1 +++ projects/cms/source/host/java/LowLevelNet.java 2001/01/24 01:25:59 1.5 @@ -1,34 +1,56 @@ -import java.net.*; +//---PACKAGE DECLARATION--- +//---IMPORTS--- +import java.net.*; +import java.io.*; + /** -* LowLevelNet - Basic Netowking Class for Java Host

-* Version 1.0

-* Version History:
-* 16/11/00 1.0 Initial Version
-*
-* @author Ash Beeson ab11@ukc.ac.uk -*/ + * Provides low level network functions for JavaHost + * + * + * @author $Author: tdb $ + * @version $Id: LowLevelNet.java,v 1.5 2001/01/24 01:25:59 tdb Exp $ + */ class LowLevelNet { - /** - * sendUDPPacket - will attempt to send a UDP packet containing 'inText' to server - * on the specificed port. - */ - public static void sendUDPPacket( Config config, String inText ){ - - if ( inText.length() != 0 ){ - - // will throw an exception if an error occurs, so must bung it in a try - // try { - DatagramPacket udp = new DatagramPacket( inText.getBytes(), inText.length(), config.getFilterName(), config.getFilterUDPPort() ); - // } - //catch ( UnknownHostException e ){ - // the serverName supplied could not be resolved using dns - // } - } - } +//---FINAL ATTRIBUTES--- - +//---STATIC METHODS--- + + /** + * sendUDPPacket - will attempt to send a UDP packet containing 'inText' to server + * on the specificed port. + */ + public static void sendUDPPacket( Config config, String inText ){ + + if ( inText.length() != 0 ){ + //System.out.println("SENT: "+inText); + // will throw an exception if an error occurs, so must bung it in a try + try { + DatagramPacket udp = new DatagramPacket( inText.getBytes(), inText.length(), config.getFilterName(), config.getFilterUDPPort() ); + DatagramSocket sendSoc = new DatagramSocket(); + sendSoc.send(udp); + } + catch ( SocketException e ){ + // the serverName supplied could not be resolved using dns + } + catch ( IOException e ){ + // problem sending.. + } + } + } + +//---CONSTRUCTORS--- + +//---PUBLIC METHODS--- + +//---PRIVATE METHODS--- + +//---ACCESSOR/MUTATOR METHODS--- + +//---ATTRIBUTES--- + +//---STATIC ATTRIBUTES--- -} \ No newline at end of file +}