com.java4less.sms.adapters
Class TcpIpAdapter

java.lang.Object
  |
  +--com.java4less.sms.adapters.TcpIpAdapter
All Implemented Interfaces:
Adapter

public class TcpIpAdapter
extends java.lang.Object
implements Adapter

This class is used to access the SMSC using a TCIP/IP (internet) connection.

  // create object
 TcpIpAdapter tcp=new TcpIpAdapter();
 tcp.connect(ServerAddress,port);

  // send the sms now using the tcp/ip adapter
  SmsSender sender=new SmsSender(tcp);
  sender.createSMS51("123","456","Hello");
  sender.sendMessage();

  tcp.disconnect();
 


Constructor Summary
TcpIpAdapter()
          constructor
TcpIpAdapter(java.net.Socket s)
          create the tcp adapter using an existing object, this is used by the acceptConnection method only
 
Method Summary
 TcpIpAdapter acceptConnection()
          wait for conections.
 void connect(java.lang.String server, int port)
          establish connection to SMSC server
 void createServer(int port)
          create a socket server (if this adapter will receive incomming conenctions)
 void disconnect()
          end connection
 byte[] receiveData(java.lang.String endDelimiter, int ptout)
          receive bytes until the delimiter is received, it wait a maximum of tout milliseconds
 void stopServer(int port)
          create a socket server
 boolean transmitBytes(byte[] b, int len)
          transmit bytes.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TcpIpAdapter

public TcpIpAdapter()
constructor


TcpIpAdapter

public TcpIpAdapter(java.net.Socket s)
             throws java.lang.Exception
create the tcp adapter using an existing object, this is used by the acceptConnection method only

Method Detail

connect

public void connect(java.lang.String server,
                    int port)
             throws java.lang.Exception
establish connection to SMSC server

java.lang.Exception

createServer

public void createServer(int port)
                  throws java.lang.Exception
create a socket server (if this adapter will receive incomming conenctions)

java.lang.Exception

stopServer

public void stopServer(int port)
                throws java.lang.Exception
create a socket server

java.lang.Exception

acceptConnection

public TcpIpAdapter acceptConnection()
                              throws java.lang.Exception
wait for conections. Example of use:
  TcpIpAdapter tcp=new TcpIpAdapter();
  // Create socket
  tcp.createServer(portNumber);
  // wait for a connectiond
  TcpIpAdapter newConnection=tcp.acceptConnection();
  // got connection

 

java.lang.Exception

disconnect

public void disconnect()
                throws java.lang.Exception
end connection

java.lang.Exception

transmitBytes

public boolean transmitBytes(byte[] b,
                             int len)
transmit bytes.

Specified by:
transmitBytes in interface Adapter

receiveData

public byte[] receiveData(java.lang.String endDelimiter,
                          int ptout)
receive bytes until the delimiter is received, it wait a maximum of tout milliseconds

Specified by:
receiveData in interface Adapter