Hi all, i'm very very new to networking and was wondering if it's possible using this code to "listen" or get some data of what's happening using this code..... when i compile and run nothing is outputted (im using port 80 since it's http so i suppose browsing). Thanks for any info....
If the client and server are the same platform, then that println() issue is probably not the problem. Additionally, when you say you "changed to print()", did you include an explicit "\r\n" as the article indicated?
The real problem, however, if you're connecting to a web server that's using the HTTP protocol, is that you can't just connect and start reading. You have to tell it what you want. For instance, when you point your browser to http://www.coderanch.com/forums, what's happening is that the browser is opening a socket to www.coderanch.com and then writing the request GET /forums\r\n[tt]. An HTTP server doesn't send anything until it receives a request from the client.
You could alter your code to send the appropriate [tt]GET request, or you could use the HttpXyz classes in the core API, or a third party HTTP library. If all you want to do is just fetch a simple page, then sending the GET yourself is probably fine. For anything more complex though--HTTP headers, other request types, handling redirects, etc., you'll want as much pre-rolled as you can get.
Joined: Mar 30, 2011
yes i did include the \r\n but still i didn't get anything, but the way you explained it makes sense about sending a request. I don't want to do anything specific, i just want to play with the code to see what's happening and which piece of code is doing what, after all im still a beginner and i suppose it's all part of the fun and learning......
Thanks again and are the classes called HttpXyz so as to read about them ?
btw yes, the client and server are the same platform.