--- projects/cms/source/host/java/LowLevelNet.java 2000/11/27 19:44:50 1.1 +++ projects/cms/source/host/java/LowLevelNet.java 2002/05/18 18:15:57 1.6 @@ -1,34 +1,75 @@ -import java.net.*; +/* + * i-scream central monitoring system + * Copyright (C) 2000-2002 i-scream + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ +//---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.6 2002/05/18 18:15:57 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 +}