Connect to JPOS Server through Java Socket

606 views
Skip to first unread message

Fandi Akhmad

unread,
Feb 15, 2016, 11:37:58 PM2/15/16
to jPOS Users
Hello, i created JPOS Server that implements ISORequestListener
So i have process method inside it.

My client, in my assumption using Java Socket to send request to my JPOS Server.
When i implement that, I can't connect to JPOS Server and JPOS server not execute process method.

Is my client correct?

public class TCPClient {
   
private Socket client;
   
private String dataFromServer;
   
private String dataToServer;
   
   
public void connect() {
       
try {
            client
= new Socket("localhost", 3092);
           
           
while (true) {
               
// Reader
               
BufferedReader inFromClient     = new BufferedReader(new InputStreamReader(System.in));
               
BufferedReader inFromServer        = new BufferedReader(new InputStreamReader(client.getInputStream()));
               
               
// Stream
               
DataOutputStream outToServer     = new DataOutputStream(client.getOutputStream());
               
                dataToServer    
= inFromClient.readLine();
                outToServer
.writeBytes(dataToServer + '\n');
               
                dataFromServer    
= inFromServer.readLine();
               
System.out.println("Response : ");
               
System.out.println(dataFromServer);
               
                client
.close();
           
}
       
} catch (Exception e) {
           
System.err.println(e.getMessage());
       
}
   
}
   
     
public static void main(String argv[]) {
         
TCPClient tcpClient = new TCPClient();
         tcpClient
.connect();
     
}
}

Thank you very much,

Mark Salter

unread,
Feb 16, 2016, 2:17:41 AM2/16/16
to jpos-...@googlegroups.com
On 16/02/16 04:37, Fandi Akhmad wrote:
> Is my client correct?

You need to ask a 'smart' question.

Include detail like :-

- as a Client if you are providing a Socket for the other system to
connect or if you are connecting into a Socket they provide.
- Which end initiates the connection
- why you are not using jPOS components and trying to roll your own.

--
Mark

Alejandro Revilla

unread,
Feb 17, 2016, 7:56:26 PM2/17/16
to jPOS Users
Why don't you use jPOS on your client side too ?


Fandi Akhmad

unread,
Feb 17, 2016, 9:10:07 PM2/17/16
to jPOS Users
Actually, I just provide a Server that handle ISO message request.
I think in general, the client's requests  are byte stream with ISO message format.

Why i don't use another Socket Server?
before i decide to use JPOSServer is make the server using Java ServerSocket, but it still have many issues.
And right now, i still research on Apache Mina, Netty etc.

And still in my mind, JPOSServer is the best fit as ISO Server.

May be you have another recommendation, about my problem? ^^
Thank you anyway

Mark Salter

unread,
Feb 18, 2016, 1:46:17 AM2/18/16
to jpos-...@googlegroups.com
On 18/02/16 02:10, Fandi Akhmad wrote:
>
> May be you have another recommendation, about my problem? ^^
Provide the details of your problem in a smart question
( http://www.catb.org/esr/faqs/smart-questions.html#intro )
and we might have somewhere to start trying to help.

--
Mark
Reply all
Reply to author
Forward
0 new messages