# TCPSocket.send is erroring

**URL:** <https://www.ruby-forum.com/t/tcpsocket-send-is-erroring/180301>\
**Category:** Ruby\
**Created:** [December 17, 2009, 12:10am UTC](https://www.ruby-forum.com/t/tcpsocket-send-is-erroring/180301 "2009-12-17T00:10:32Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Philliam\_A](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/278dde/32.png) [@Philliam\_A](https://www.ruby-forum.com/u/Philliam_A)\
**Post date:** [December 17, 2009, 12:10am UTC](https://www.ruby-forum.com/t/tcpsocket-send-is-erroring/180301/1 "2009-12-17T00:10:32Z")

</div>

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](http://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?

---

<div class="post-metadata">

**Author:** ![Philliam\_A](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/278dde/32.png) [@Philliam\_A](https://www.ruby-forum.com/u/Philliam_A)\
**Post date:** [December 17, 2009, 12:57am UTC](https://www.ruby-forum.com/t/tcpsocket-send-is-erroring/180301/2 "2009-12-17T00:57:06Z")

</div>

> streamSock.send(“Hello\n”)  
> ArgumentError: wrong number of arguments (1 for 2)

[http://rubydoc.ruby-forum.com/doc/ruby-1.9.1-p129/classes/BasicSocket.html#M002537](http://rubydoc.ruby-forum.com/doc/ruby-1.9.1-p129/classes/BasicSocket.html#M002537)

might be helpful.

I think what you want is “write” which writes an entire string  
[basically blocks until the entire string is written].
