From: Will Dresh Date: 2008-08-31T01:09:32+09:00 Subject: Simple, simple socket question Hello all, I am very sorry if this has already been asked and answered; I have, however, searched to the best of my ability and cannot seem to come up with anything. I am merely a beginner with real programming languages, however I am very experienced with higher-level scripting languages, and have worked extensively with sockets in mIRCscript. Here is my attempt at my very first Ruby socket program: require 'socket' mySock = TCPSocket::new('www.google.com', 80) mySock.write('GET / HTTP/1.1\n') mySock.write('Host: www.google.com\n') mySock.write('\n') data = mySock.recv(128) mySock.close puts data I would expect for this program to output the first 128 bytes of Google's HTML headers and code. When this program is run, it simply hangs on the console window and does not appear to do, well, anything. Even if I replace puts data with puts 'hi', the program still yields no result. Why? What is needed to make this code work as expected? Also, in reading many different Ruby socket tutorials, I am unable to distinguish between two socket-related methods that I've encountered: send and write. I've attempted using both. In every tutorial I've encountered, the send method is called with only one String parameter (just like my calls to write in the above code), however when I try to emulate this, Ruby tells me that send requires two parameters, the second of which must be an Integer. So, my questions here are, what does this Integer parameter represent, and why is it needed? And, what exactly is the difference between the write and send methods? Thank you so much for your time, -Will -- Posted via http://www.ruby-forum.com/.