Skip to content

struct Socket::UNIXAddress
inherits Socket::Address

UNIX address representation.

Holds the local path of an UNIX address, usually coming from an opened connection (e.g. Socket#local_address, Socket#receive).

Example:

require "socket"

Socket::UNIXAddress.new("/tmp/my.sock")

Class methods

.parse(uri : String)

Parses a Socket::UNIXAddress from an URI.

It expects the URI to include <scheme>://<path> where scheme as well as any additional URI components (such as fragment or query) are ignored.

If host is not empty, it will be prepended to path to form a relative path.

require "socket"

Socket::UNIXAddress.parse("unix:///foo.sock") # => Socket::UNIXAddress.new("/foo.sock")
Socket::UNIXAddress.parse("unix://foo.sock")  # => Socket::UNIXAddress.new("foo.sock")
View source

.from(sockaddr : Pointer(LibC::Sockaddr), addrlen) : UNIXAddress

Creates an UNIXSocket from the internal OS representation.

View source

.new(path : String)

View source

.parse(uri : URI) : UNIXAddress

Parses a Socket::UNIXAddress from an URI.

It expects the URI to include <scheme>://<path> where scheme as well as any additional URI components (such as fragment or query) are ignored.

If host is not empty, it will be prepended to path to form a relative path.

require "socket"

Socket::UNIXAddress.parse("unix:///foo.sock") # => Socket::UNIXAddress.new("/foo.sock")
Socket::UNIXAddress.parse("unix://foo.sock")  # => Socket::UNIXAddress.new("foo.sock")
View source

Methods

#==(other : self)

#hash(hasher)

#to_s(io : IO) : Nil

Same as #inspect(io).

View source

#to_unsafe : Pointer(LibC::Sockaddr)

View source