Here is my code... Im having problems. Here is the two functions and attached is an image that has the output... Im getting a "StreamCorruptedException" when I try to get the input stream. No problem with the output stream.
Code:public boolean attemptServerConnection(String host, int port) { my_hostaddr = new String( host ); my_port = port; String getMessage; try { _debug("attempting connection to " + my_hostaddr + " ..."); my_conn = new Socket( my_hostaddr, my_port ); _debug("connected ok? - " + my_conn.isConnected()); _debug("getting output streams..."); output = new ObjectOutputStream( my_conn.getOutputStream() ); _debug("flushing now...\n=============="); output.flush(); _debug("==============\ndone flushing"); _debug("writing message to " + my_hostaddr + " ..."); getMessage = "GET / http://" + my_hostaddr + " HTTP/1.0\r\n"; getMessage += "Host: http://" + my_hostaddr + "\r\n"; getMessage += "\r\n"; output.writeObject(getMessage); output.flush(); _debug("getting input streams..."); input = new ObjectInputStream( my_conn.getInputStream() ); _debug("closing output buffer"); output.close(); _debug("closing connection"); my_conn.close(); } catch(Exception e) { _debug("UH OH! Exception " + e.toString() + " and it was caused by " + e.getMessage()); } return true; } public void _debug(String msg) { System.out.println(msg + "\n"); }
The website works fine... Thanks for any input!
Here is the output:![]()


Reply With Quote


Bookmarks