W3cubDocs

/Crystal

abstract struct Socket::Address

Direct Known Subclasses

Defined in:

socket/address.cr

Constructors

Class Method Summary

Instance Method Summary

Constructor Detail

def self.from(sockaddr : Pointer(LibC::Sockaddr), addrlen) : AddressSource

Returns either an IPAddress or UNIXAddres from the internal OS representation. Only INET, INET6 and UNIX families are supported.

def self.new(family : Family, size : Int32)Source

Class Method Detail

def self.parse(uri : URI)Source

Parses a Socket::Address from an URI.

Supported formats:

  • ip://:
  • tcp://:
  • udp://:
  • unix://

See IPAddress.parse and UNIXAddress.parse for details.

def self.parse(uri : String)Source

Parses a Socket::Address from an URI.

Supported formats:

  • ip://:
  • tcp://:
  • udp://:
  • unix://

See IPAddress.parse and UNIXAddress.parse for details.

Instance Method Detail

def ==(other)Source

Description copied from struct Struct

Returns true if this struct is equal to other.

Both structs's instance vars are compared to each other. Thus, two structs are considered equal if each of their instance variables are equal. Subclasses should override this method to provide specific equality semantics.

struct Point
  def initialize(@x : Int32, @y : Int32)
  end
end

p1 = Point.new 1, 2
p2 = Point.new 1, 2
p3 = Point.new 3, 4

p1 == p2 # => true
p1 == p3 # => false

def family : FamilySource

def size : Int32Source

abstract def to_unsafe : Pointer(LibC::Sockaddr)Source

© 2012–2020 Manas Technology Solutions.
Licensed under the Apache License, Version 2.0.
https://crystal-lang.org/api/0.35.1/Socket/Address.html