TCPSocket.send is erroring

P

Philliam Auriemma

Hello, I seem to be experiencing a problem.

I am a python programmer who is trying ruby, and I am liking it so
far. I do need help on an issue I am having though.

I am creating a TCP socket and attempting to send data through it,
with the following code, which was taken almost verbatim from a
website:

require 'socket'
streamSock = TCPSocket::new("www.ibm.com", 80)
streamSock.send("Hello\n")

and I get this error:

ArgumentError: wrong number of arguments (1 for 2)

So I try passing it an integer, and I guess that the second argument
may be the length of what to send, so I put in 6, as in

streamSock.send("Hello\n", 6)

But then I get this error:

Errno::EOPNOTSUPP: The attempted operation is not supported for the
type of object referenced. - send(2)

I can't figure out what's wrong. Can anyone help me figure this out?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,767
Messages
2,569,570
Members
45,045
Latest member
DRCM

Latest Threads

Top