IPSocket
Inherits Socket / Crystal::System::Socket / IO::Buffered / IO / Reference / Object
NOTE: To use IPSocket, you must explicitly import it with require "socket/ip_socket"
Instance methods
bind(addr)
Sourceconnect(addr, timeout = nil, &)
Tries to connect to a remote address. Yields an IO::TimeoutError or an
Socket::ConnectError error if the connection failed.
Sets whether an IPv6 socket will accept IPv4 clients / packets
require "socket"
server = UDPSocket.new(:inet6)
# enable IPv6 dual stack, accepting IPv4 clients
server.ipv6_only = false
server.bind "::1", 1234
message = Bytes.new(32)
bytes_read, client_addr = server.receive(message)