Hi Tim Holloway ,
Thanks for your reply ...
No , i donot want to have a connection with webserver.
i want to make a connection using socket(tcp /ip communication).
Please see the following for the client side code
Client
*********
//open the connection
InetAddress hostAddr = InetAddress.getByName(IPADDRESS);
int hostPort = PORT;
Socket soc = new Socket(hostAddr,hostPort);
//Send value to server
PrintWriter theWriter = new PrintWriter(soc.getOutputStream(),true);
theWriter.println("Hi from client ");
//receive the data from the server
String input = "NoValue";
BufferedReader theReader = new BufferedReader(new InputStreamReader(soc.getInputStream()));
while((input = theReader.readLine()) != null)
System.out.println("SERVER REPLIED : " + input + "\n");
//close the socket ,I/O stream
theReader.close();
theWriter.close();
soc.close();
***** end of the part of the code *****
now i want to split the above stpes into separate methods
for example,
open
close
send
receive
so from another class ie at the start point- may be login time) of the applicaion i can call open method to establish the connection and i can call send and receive method for many time s to send and receive the data and in the end point(may be loged out ) of the application i can call close method to close the socket.
Hope now you can have an idea about what i am asking....
i want to save the time for open and close the socket for each and every request and response.
Thanks & Regards,
Sangeeth