View Single Post
Join Date: Nov 2008
Posts: 249
Reputation: Antenka has a spectacular aura about Antenka has a spectacular aura about Antenka has a spectacular aura about 
Solved Threads: 65
Antenka's Avatar
Antenka Antenka is offline Offline
Posting Whiz in Training

Problem with remote applications interaction using URL

 
0
  #1
Nov 16th, 2008
Hello everyone, beforehand, sorry for my english...
I have to do client - server application. They must interact, using classes URL, URLConnection. I understand, how to send data to server. But I can not realize server work.
The common algorithm of server is:
1. Start.
2. Wait for connection.
3. After receiving connection it must process request.
4. Or back for "2" or exit.

as I understand, client code to send request is:
  1. URL url = new URL ("http://" + host + ":" + port);
  2. URLConnection c = url.openConnection();
  3. c.setDoOutput(true);
  4. c.connect();
  5.  
  6. OutputStreamWriter out = new OutputStreamWriter(c.getOutputStream());
  7. out.write(URLEncoder.encode(request,"UTF-8") );
  8. out.flush();
  9. out.close();
please help with server code to catch this connection?
So what if you can see the darkest side of me?
No one would ever change this animal I have become
Help me believe it's not the real me
Somebody help me tame this animal
Reply With Quote