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
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:
data = mySock.recv(128)
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,