plz help me(its urgent)

Socket sc=null;

PrintWriter ps=null;

BufferedReader in=null;

String userinput="";

try{

System.out.println("Conecting payment Client");

sc=new Socket("103.137.102.13",6151);

System.out.println("getInetAddress:::::"+sc.getInetAddress());

System.out.println("getLocal Port:::::"+sc.getPort());

ps= new PrintWriter(sc.getOutputStream());

in=new BufferedReader(new InputStreamReader(sc.getInputStream()));

ps.print("1,Test\n");

userinput=in.readLine();System.out.println("userinput::::::"+userinput);

if(!userinput.equals("1,echo:Test")){

System.out.println("Not EQual::"+userinput);

}

}catch(UnknownHostException e){

System.out.println("Host name not found");

}catch(IOException e){

System.out.println("I/O error");

}

Hi userinput I am getting null.

But Actully userinput has to get Test.

Can u plz tell me what i did mistkae

[980 byte] By [6666a] at [2007-10-3 9:12:34]
# 1
The server is closing the socket straight away instead of sending any data.
ejpa at 2007-7-15 4:24:50 > top of Java-index,Archived Forums,Socket Programming...
# 2
forget it.Message was edited by: masijade.
masijade.a at 2007-7-15 4:24:50 > top of Java-index,Archived Forums,Socket Programming...
# 3
Sorry,I am not getting what u r saying.How can i reolve this problem
6666a at 2007-7-15 4:24:50 > top of Java-index,Archived Forums,Socket Programming...
# 4
What part of 'the server is closing the socket straight away instead of sending any data' don't you understand?
ejpa at 2007-7-15 4:24:50 > top of Java-index,Archived Forums,Socket Programming...
# 5
Hi, I am new to Socket programing.Dont take serious.U r telling Server is closing.If u dont mind how can I send data without closing the server.
6666a at 2007-7-15 4:24:50 > top of Java-index,Archived Forums,Socket Programming...
# 6
Without seeing the server code I have no idea.The server is the problem. You have only shown the client code.
ejpa at 2007-7-15 4:24:50 > top of Java-index,Archived Forums,Socket Programming...
# 7
Hi, Actaullay I am doing payment Gate way task.In the spec Given host name and ip address.(In that pay Clint Application installed.Its aj ava pplication).I think no need to write server program.paymnet Client act as a server.So How can I check Server Program?
6666a at 2007-7-15 4:24:50 > top of Java-index,Archived Forums,Socket Programming...
# 8

This makes no sense. This piece of code is a client. A Java program can only act as a server to this client by creating a ServerSocket. This code doesn't do that so it is not a server. It creates a Socket so it is a client. Somewhere there is a server for this client. What is it? What does this client connect to, and why does it close the socket immediately rather than sending what this client expects? That's the question you have to solve.

ejpa at 2007-7-15 4:24:50 > top of Java-index,Archived Forums,Socket Programming...
# 9

Maybe I should not have deleted my post.

You cannot simply attempt to open a socket and then expect a message sent out over that Sockets OutputStream to magically loopback to that same Sockets InputStream.

Sending that message test to the Gateway server is probably what caused it close the connection, since it probably did not understand what you wanted.

You will only be able to communicate to the server using protocol it understands, so dig out your manual for it and find out how you can test for it. If you don't have access to this info, then contact the company that produces the server and ask them.

masijade.a at 2007-7-15 4:24:50 > top of Java-index,Archived Forums,Socket Programming...