Class: Socket::SockAddr_Un
- Inherits:
-
Struct
- Object
- Struct
- Socket::SockAddr_Un
- Defined in:
- lib/rubysl/socket.rb
Instance Method Summary collapse
-
#initialize(filename = nil) ⇒ SockAddr_Un
constructor
A new instance of SockAddr_Un.
- #to_s ⇒ Object
Constructor Details
#initialize(filename = nil) ⇒ SockAddr_Un
Returns a new instance of SockAddr_Un.
811 812 813 814 815 816 817 818 819 820 821 822 |
# File 'lib/rubysl/socket.rb', line 811 def initialize(filename = nil) maxfnsize = self.size - (FFI.config("sockaddr_un.sun_family.size") + 1) if filename and filename.length > maxfnsize raise ArgumentError, "too long unix socket path (max: #{maxfnsize}bytes)" end @p = FFI::MemoryPointer.new self.size if filename @p.write_string( [Socket::AF_UNIX].pack("s") + filename ) end super @p end |
Instance Method Details
#to_s ⇒ Object
824 825 826 |
# File 'lib/rubysl/socket.rb', line 824 def to_s @p.read_string self.size end |