This is a very simple way. Since you have client I assume there is a way to encode/decode bytes into SMPP packet.
public void runServer() throws Exception
{
ServerSocket serverSocket = new ServerSocket(6868);
Socket socket = serverSocket.accept();
while (socket.isBound()) {
byte[] bytes = readBytes(socket.getInputStream()) ;
- encode bytes to smpp
- create smpp response and decode to bytes
socket.getOutputStream().write(bytes);
socket.getOuptutStream().flush();
}
socket.close();
serverSocket.close();
}
private byte[] readBytes(InputStream is) throws Exception
{
ByteArrayOutputStream baos = new ByteArrayOutputStream();
int i ;
while ((i=is.read()) != -1) baos.write(i);
return baos.toByteArray();
}
If you want more bullet proof code, then after server accept you create a
worker thread, which runs separately, while server is accepting another connections.