NOTE To use IPSocket, you must explicitly import it with require "socket/ip_socket"
Flushes and closes the underlying IO.
Tries to connect to a remote address.
Sets whether an IPv6 socket will accept IPv4 clients / packets
Reports whether IPv4 packets are accepted by the socket.
Returns the IPAddress for the local end of the IP socket.
Returns the IPAddress for the remote end of the IP socket.
Socket
Socket
Socket
Crystal::System::Socket
Crystal::System::Socket
IO::Buffered
IO
IO
Reference
Reference
Reference
Object
Object
Object
Flushes and closes the underlying IO.
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)
Returns the IPAddress for the local end of the IP socket.
Returns the IPAddress for the remote end of the IP socket.
© 2012–2026 Manas Technology Solutions.
Licensed under the Apache License, Version 2.0.
https://crystal-lang.org/api/1.19.0/IPSocket.html