Flowdock
method

tcp

Importance_1
tcp(host, port, local_host=nil, local_port=nil) public

creates a new socket object connected to host:port using TCP/IP.

If local_host:local_port is given, the socket is bound to it.

If a block is given, the block is called with the socket. The value of the block is returned. The socket is closed when this method returns.

If no block is given, the socket is returned.

Socket.tcp("www.ruby-lang.org", 80) {|sock|
  sock.print "GET / HTTP/1.0\r\nHost: www.ruby-lang.org\r\n\r\n"
  sock.close_write
  puts sock.read
}
Show source
Register or log in to add new notes.