wood burning stoves 2.0*
The moose likes Sockets and Internet Protocols and the fly likes socket output writing problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "socket output writing problem" Watch "socket output writing problem" New topic
Author

socket output writing problem

Jeff Yan
Ranch Hand

Joined: Nov 05, 2009
Posts: 42
hey,

im having trouble getting my java server to write to the socket to get a browser to read the html it has been sent, the browser just waits for a response!!

i dont know what else to do, i need to be able to have html the server sends readable by 127.0.0.1:PORT

here is the code:


any help appreciated

~ Jeff Yan ~
Lester Burnham
Rancher

Joined: Oct 14, 2008
Posts: 1337
The server design is a bit odd. I suggest to work through the Java Networking Tutorial, especially the section Writing a Client/Server Pair.
Jeff Yan
Ranch Hand

Joined: Nov 05, 2009
Posts: 42
in what sense is it odd?? i need some constructive critasism. the problem with that tutorial is that i do not want to implement that knock knock protocol! i want it to be able to receive a GET request and process it accordingly, either getting a requested webpage or directory / file.
Lester Burnham
Rancher

Joined: Oct 14, 2008
Posts: 1337
Ah - HTTP. That's a bit different from most other TCP/IP protocols (in that it closes the connection after the response, unless Keep-Alive is used), and the code you have accordingly more "normal". One issue that often leads to "hangs" is Don't println to a Socket (which this code does, via the "readLine" call).

A second issue is that HTTP ends lines using "\r\n" - this code uses just a newline.

Lastly, HTTP (even just GET) is a lot more complex than what this code does, but I assume you have read the relevant specification, so you know that already.
Satya Maheshwari
Ranch Hand

Joined: Jan 01, 2007
Posts: 368
You may also want to put in a packet sniffer on your client and see how is the server response differing from an actual GET response. That may reveal if anything else is missing.


Thanks and Regards
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: socket output writing problem
 
Similar Threads
a total newbie in Sockets
Server/Client Socket Connection
accessing a server using socket connection
Why won't my program compile?
Writing to files using socket server