class

TCPSocket

Inherits IPSocket / Socket / Crystal::System::Socket / IO::Buffered / IO / Reference / Object

A Transmission Control Protocol (TCP/IP) socket.

NOTE: To use TCPSocket, you must explicitly import it with require "socket"

Usage example:

require "socket"

client = TCPSocket.new("localhost", 1234)
client << "message\n"
response = client.gets
client.close

Constructors

new(host, port, dns_timeout = nil, connect_timeout = nil, blocking = false)

Preserve a hostname, if one is given. Nothing downstream preserves it, and it doesn't make sense to lose that information. Many of the semantic conventions for various types of spans really want to have this information.

Source

Instance methods

hostname
Source