A local interprocess communication clientsocket.
Only available on UNIX and UNIX-like operating systems.
Example usage:
require "socket" sock = UNIXSocket.new("/tmp/myapp.sock") sock.puts "message" response = sock.gets sock.close
Connects a named UNIX socket, bound to a filesystem pathname.
Creates a UNIXSocket from an already configured raw file descriptor
Opens an UNIX socket to a filesystem pathname, yields it to the block, then eventually closes the socket when the block returns.
Returns a pair of unamed UNIX sockets.
Creates a pair of unamed UNIX sockets (see .pair
) and yields them to the block.
Receives a text message from the previously bound address.
Socket
Socket
Socket
IO::Evented
IO::Buffered
IO
IO
Reference
Reference
Object
Object
Connects a named UNIX socket, bound to a filesystem pathname.
Creates a UNIXSocket from an already configured raw file descriptor
Opens an UNIX socket to a filesystem pathname, yields it to the block, then eventually closes the socket when the block returns.
Returns the value of the block.
Returns a pair of unamed UNIX sockets.
require "socket" left, right = UNIXSocket.pair spawn do # echo server message = right.gets right.puts message end left.puts "message" left.gets # => "message"
Creates a pair of unamed UNIX sockets (see .pair
) and yields them to the block. Eventually closes both sockets when the block returns.
Returns the value of the block.
Receives a text message from the previously bound address.
require "socket" server = Socket.udp(Socket::Family::INET) server.bind("localhost", 1234) message, client_addr = server.receive
© 2012–2020 Manas Technology Solutions.
Licensed under the Apache License, Version 2.0.
https://crystal-lang.org/api/0.35.1/UNIXSocket.html