ie.omk.smpp.net
Class TcpLink

java.lang.Object
  extended by ie.omk.smpp.net.SmscLink
      extended by ie.omk.smpp.net.TcpLink

public class TcpLink
extends SmscLink

Implementation of an Smsc link over the tcp/ip protocol

Version:
$Id: TcpLink.java 302 2006-08-10 20:36:40Z orank $
Author:
Oran Kelly

Field Summary
static int DEFAULT_PORT
          Default IP port to use if none are specified
 
Constructor Summary
TcpLink(InetAddress address)
          Create a new TcpLink
TcpLink(InetAddress address, int port)
          Create a new TcpLink
TcpLink(String address)
          Create a new TcpLink
TcpLink(String address, int port)
          Create a new TcpLink
 
Method Summary
 InetAddress getAddress()
          Get the address we're connected (or connecting) to.
 int getConnectedPort()
          Get the port at the SMSC that this link is connected to.
protected  InputStream getInputStream()
          Get the input stream of the Socket connection to the SMSC.
 int getLocalPort()
          Get the local port number this link is connected to.
protected  OutputStream getOutputStream()
          Get the output stream of the Socket connection to the SMSC.
 int getPort()
          Get the service port to connect to at the SMSC to establish a TCP connection.
 int getTimeout()
          Get the value for read timeout.
protected  void implClose()
          Close the Socket connection to the SMSC.
protected  void implOpen()
          Create a new Socket connection to the SMSC.
 boolean isConnected()
          Check connection status.
 void setTimeout(int timeout)
          Set the socket timeout (SO_TIMEOUT).
 void setTimeout(long timeout)
          Deprecated. Use setTimeout(int)
 
Methods inherited from class ie.omk.smpp.net.SmscLink
available, close, flush, getAutoFlush, open, read, setAutoFlush, setSnoopStreams, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_PORT

public static final int DEFAULT_PORT
Default IP port to use if none are specified

See Also:
Constant Field Values
Constructor Detail

TcpLink

public TcpLink(String address)
        throws UnknownHostException
Create a new TcpLink

Parameters:
address - IP address or hostname of SMSC
Throws:
UnknownHostException - If the host is not found.

TcpLink

public TcpLink(String address,
               int port)
        throws UnknownHostException
Create a new TcpLink

Parameters:
address - IP address or hostname of SMSC
port - The port number to connect to
Throws:
UnknownHostException - If the host is not found.

TcpLink

public TcpLink(InetAddress address)
        throws UnknownHostException
Create a new TcpLink

Parameters:
address - IP address SMSC
Throws:
UnknownHostException - If the host is not found.

TcpLink

public TcpLink(InetAddress address,
               int port)
        throws UnknownHostException
Create a new TcpLink

Parameters:
address - IP address of SMSC
port - The port number to connect to
Throws:
UnknownHostException - If the host is not found.
Method Detail

implOpen

protected void implOpen()
                 throws IOException
Create a new Socket connection to the SMSC. This implementation creates a new instance of a java.net.Socket with the host name and port supplied to the constructor an instance of this class was created with.

Specified by:
implOpen in class SmscLink
Throws:
IOException - If an error occurs while creating the socket connection to the SMSC.
See Also:
Socket.Socket(java.net.InetAddress, int)

implClose

protected void implClose()
                  throws IOException
Close the Socket connection to the SMSC.

Specified by:
implClose in class SmscLink
Throws:
IOException - If an I/O error occurs closing the socket connection.
See Also:
Socket.close()

getOutputStream

protected OutputStream getOutputStream()
                                throws IOException
Get the output stream of the Socket connection to the SMSC.

Specified by:
getOutputStream in class SmscLink
Throws:
IOException - If the socket connection is not open or an I/O error occurs when creating the output stream.
See Also:
OutputStream, Socket.getOutputStream()

getInputStream

protected InputStream getInputStream()
                              throws IOException
Get the input stream of the Socket connection to the SMSC.

Specified by:
getInputStream in class SmscLink
Throws:
IOException - If the socket connection is not open or an I/O error occurs when creating the input stream.
See Also:
InputStream, Socket.getInputStream()

getAddress

public InetAddress getAddress()
Get the address we're connected (or connecting) to.

Returns:
The address of the SMSC this link is connected to.

getPort

public int getPort()
Get the service port to connect to at the SMSC to establish a TCP connection.

Returns:
The service port at the SMSC to connect to.

getConnectedPort

public int getConnectedPort()
                     throws IOException
Get the port at the SMSC that this link is connected to. This is the remote port that this link is connected to after a successful connection has been made.

Returns:
The remote port this link is connected to.
Throws:
IOException - If the connection is not open.

getLocalPort

public int getLocalPort()
                 throws IOException
Get the local port number this link is connected to.

Returns:
The local port number this link is connected to.
Throws:
IOException - If the connection is not open.

isConnected

public boolean isConnected()
Check connection status.

Specified by:
isConnected in class SmscLink
Returns:
false if unconnected, true if connected.

setTimeout

public void setTimeout(int timeout)
Set the socket timeout (SO_TIMEOUT).

Overrides:
setTimeout in class SmscLink
Parameters:
timeout - The timeout to set.

setTimeout

public void setTimeout(long timeout)
Deprecated. Use setTimeout(int)

Description copied from class: SmscLink
Set the value for read timeout. A link implementation may support timing out on blocking read operations. This method may be used to set such a timeout. If the implementation does not support timeouts, it must throw an UnsuppertedOperationException.

Overrides:
setTimeout in class SmscLink
Parameters:
timeout - the timeout value in milliseconds.

getTimeout

public int getTimeout()
Description copied from class: SmscLink
Get the value for read timeout.

Overrides:
getTimeout in class SmscLink
Returns:
the current value for read timeout.
See Also:
SmscLink.setTimeout(long)


Copyright © 2011 smppapi at Sourceforge. All Rights Reserved.