Class: UNIXSocket
- Inherits:
-
BasicSocket
show all
- Includes:
- IO::TransferIO
- Defined in:
- lib/rubysl/socket/socket.rb
Constant Summary
Constants inherited
from BasicSocket
BasicSocket::FFI
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from BasicSocket
#close_read, #close_write, do_not_reverse_lookup, do_not_reverse_lookup=, for_fd, from_descriptor, #getpeername, #getsockname, #getsockopt, #recv, #recv_nonblock, #send, #setsockopt, #shutdown
Constructor Details
Returns a new instance of UNIXSocket.
822
823
824
825
826
|
# File 'lib/rubysl/socket/socket.rb', line 822
def initialize(path)
@path = path
unix_setup
@path = "" end
|
Class Method Details
.socketpair(type = Socket::SOCK_STREAM, protocol = 0) ⇒ Object
Also known as:
pair
908
909
910
|
# File 'lib/rubysl/socket/socket.rb', line 908
def socketpair(type=Socket::SOCK_STREAM, protocol=0)
Socket.socketpair(Socket::PF_UNIX, type, protocol, self)
end
|
Instance Method Details
#addr ⇒ Object
879
880
881
882
883
|
# File 'lib/rubysl/socket/socket.rb', line 879
def addr
sockaddr = Socket::Foreign.getsockname descriptor
_, sock_path = sockaddr.unpack('SZ*')
["AF_UNIX", sock_path]
end
|
#from_descriptor(fixnum) ⇒ Object
837
838
839
840
|
# File 'lib/rubysl/socket/socket.rb', line 837
def from_descriptor(fixnum)
super
@path = nil
end
|
#path ⇒ Object
828
829
830
831
832
833
834
835
|
# File 'lib/rubysl/socket/socket.rb', line 828
def path
unless @path
sockaddr = Socket::Foreign.getsockname descriptor
_, @path = sockaddr.unpack('SZ*')
end
return @path
end
|
#peeraddr ⇒ Object
885
886
887
888
889
|
# File 'lib/rubysl/socket/socket.rb', line 885
def peeraddr
sockaddr = Socket::Foreign.getpeername descriptor
_, sock_path = sockaddr.unpack('SZ*')
["AF_UNIX", sock_path]
end
|
#recv_io(klass = IO, mode = nil) ⇒ Object
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
|
# File 'lib/rubysl/socket/socket.rb', line 891
def recv_io(klass=IO, mode=nil)
begin
fd = recv_fd
rescue PrimitiveFailure
raise SocketError, "file descriptor was not passed"
end
return fd unless klass
if klass < BasicSocket
klass.for_fd(fd)
else
klass.for_fd(fd, mode)
end
end
|
#recvfrom(bytes_read, flags = 0) ⇒ Object
Coding to the lowest standard here.
817
818
819
820
|
# File 'lib/rubysl/socket/socket.rb', line 817
def recvfrom(bytes_read, flags = 0)
socket_recv(bytes_read, flags, 2)
end
|