stdlib/socket/0/unix_socket.rbs in rbs-2.0.0 vs stdlib/socket/0/unix_socket.rbs in rbs-2.1.0
- old
+ new
@@ -1,7 +1,14 @@
+# <!-- rdoc-file=ext/socket/unixsocket.c -->
# UNIXSocket represents a UNIX domain stream client socket.
+#
class UNIXSocket < BasicSocket
+ # <!--
+ # rdoc-file=ext/socket/unixsocket.c
+ # - UNIXSocket.pair([type [, protocol]]) => [unixsocket1, unixsocket2]
+ # - UNIXSocket.socketpair([type [, protocol]]) => [unixsocket1, unixsocket2]
+ # -->
# Creates a pair of sockets connected to each other.
#
# *socktype* should be a socket type such as: :STREAM, :DGRAM, :RAW, etc.
#
# *protocol* should be a protocol defined in the domain. 0 is default protocol
@@ -10,12 +17,17 @@
# s1, s2 = UNIXSocket.pair
# s1.send "a", 0
# s1.send "b", 0
# p s2.recv(10) #=> "ab"
#
- def self.pair: (?Symbol socktype, ?Integer protocol) -> [instance, instance]
+ def self.pair: (?Symbol socktype, ?Integer protocol) -> [ instance, instance ]
+ # <!--
+ # rdoc-file=ext/socket/unixsocket.c
+ # - UNIXSocket.pair([type [, protocol]]) => [unixsocket1, unixsocket2]
+ # - UNIXSocket.socketpair([type [, protocol]]) => [unixsocket1, unixsocket2]
+ # -->
# Creates a pair of sockets connected to each other.
#
# *socktype* should be a socket type such as: :STREAM, :DGRAM, :RAW, etc.
#
# *protocol* should be a protocol defined in the domain. 0 is default protocol
@@ -24,40 +36,56 @@
# s1, s2 = UNIXSocket.pair
# s1.send "a", 0
# s1.send "b", 0
# p s2.recv(10) #=> "ab"
#
- def self.socketpair: (?Symbol socktype, ?Integer protocol) -> [instance, instance]
+ def self.socketpair: (?Symbol socktype, ?Integer protocol) -> [ instance, instance ]
public
+ # <!--
+ # rdoc-file=ext/socket/unixsocket.c
+ # - unixsocket.addr => [address_family, unix_path]
+ # -->
# Returns the local address as an array which contains address_family and
# unix_path.
#
# Example
# serv = UNIXServer.new("/tmp/sock")
# p serv.addr #=> ["AF_UNIX", "/tmp/sock"]
#
- def addr: () -> [String, String]
+ def addr: () -> [ String, String ]
+ # <!--
+ # rdoc-file=ext/socket/unixsocket.c
+ # - unixsocket.path => path
+ # -->
# Returns the path of the local address of unixsocket.
#
# s = UNIXServer.new("/tmp/sock")
# p s.path #=> "/tmp/sock"
#
def path: () -> String
+ # <!--
+ # rdoc-file=ext/socket/unixsocket.c
+ # - unixsocket.peeraddr => [address_family, unix_path]
+ # -->
# Returns the remote address as an array which contains address_family and
# unix_path.
#
# Example
# serv = UNIXServer.new("/tmp/sock")
# c = UNIXSocket.new("/tmp/sock")
# p c.peeraddr #=> ["AF_UNIX", "/tmp/sock"]
#
- def peeraddr: () -> [String, String]
+ def peeraddr: () -> [ String, String ]
+ # <!--
+ # rdoc-file=ext/socket/unixsocket.c
+ # - unixsocket.recv_io([klass [, mode]]) => io
+ # -->
# Example
#
# UNIXServer.open("/tmp/sock") {|serv|
# UNIXSocket.open("/tmp/sock") {|c|
# s = serv.accept
@@ -78,10 +106,14 @@
#
# *mode* is the same as the argument passed to IO.for_fd
#
def recv_io: (?singleton(BasicSocket), ?String mode) -> BasicSocket
+ # <!--
+ # rdoc-file=ext/socket/unixsocket.c
+ # - unixsocket.recvfrom(maxlen [, flags[, outbuf]]) => [mesg, unixaddress]
+ # -->
# Receives a message via *unixsocket*.
#
# *maxlen* is the maximum number of bytes to receive.
#
# *flags* should be a bitwise OR of Socket::MSG_* constants.
@@ -99,12 +131,16 @@
# s3 = UNIXSocket.for_fd(s2.fileno)
#
# s1.send "a", 0, s2_ai
# p s3.recvfrom(10) #=> ["a", ["AF_UNIX", "/tmp/sock1"]]
#
- def recvfrom: (Integer maxlen, ?Integer flags, ?String outbuf) -> [String, [String, String]]
+ def recvfrom: (Integer maxlen, ?Integer flags, ?String outbuf) -> [ String, [ String, String ] ]
+ # <!--
+ # rdoc-file=ext/socket/unixsocket.c
+ # - unixsocket.send_io(io) => nil
+ # -->
# Sends *io* as file descriptor passing.
#
# s1, s2 = UNIXSocket.pair
#
# s1.send_io STDOUT
@@ -119,9 +155,13 @@
#
def send_io: (BasicSocket | Integer) -> void
private
+ # <!--
+ # rdoc-file=ext/socket/unixsocket.c
+ # - UNIXSocket.new(path) => unixsocket
+ # -->
# Creates a new UNIX client socket connected to *path*.
#
# require 'socket'
#
# s = UNIXSocket.new("/tmp/sock")