com.partnersoft.net
Class SocketLib

java.lang.Object
  extended by com.partnersoft.net.SocketLib
All Implemented Interfaces:
Lib

public class SocketLib
extends java.lang.Object
implements Lib

Library routines to simplify dealing with TCP/IP sockets.

Copyright 2008 Partner Software, Inc.

Version:
$Id$
Author:
Paul Reavis

Method Summary
static java.lang.String exchangeText(java.lang.String server, int port, java.lang.String text)
          Exchange request text with the given TCP ported address.
static boolean isPortAvailable(int port)
          Tests to see if a TCP port is open and available - generally a good indication that a service is not currently running.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

exchangeText

public static java.lang.String exchangeText(java.lang.String server,
                                            int port,
                                            java.lang.String text)
                                     throws java.io.IOException
Exchange request text with the given TCP ported address.

Returns any reply text sent back by the server. This is a single exchange - socket is opened, request text is sent and flushed, reply text is received, socket is closed, reply text is returned.

Throws:
java.io.IOException

isPortAvailable

public static boolean isPortAvailable(int port)
Tests to see if a TCP port is open and available - generally a good indication that a service is not currently running. Use this to test for port availability before starting e.g. a native server program.

Returns:
true if port is not currently in use, false otherwise