Class: UNIXServer
- Inherits:
-
UNIXSocket
- Object
- IO
- BasicSocket
- UNIXSocket
- UNIXServer
- Defined in:
- ext/enterprise_script_service/mruby/mrbgems/mruby-socket/mrblib/socket.rb
Constant Summary
Constants inherited from IO
IO::BUF_SIZE, IO::SEEK_CUR, IO::SEEK_END, IO::SEEK_SET
Instance Attribute Summary
Attributes inherited from BasicSocket
Instance Method Summary collapse
- #accept ⇒ Object
- #accept_nonblock ⇒ Object
-
#initialize(path) ⇒ UNIXServer
constructor
A new instance of UNIXServer.
- #listen(backlog) ⇒ Object
- #sysaccept ⇒ Object
Methods inherited from UNIXSocket
#addr, #path, #peeraddr, #recvfrom, socketpair
Methods inherited from BasicSocket
do_not_reverse_lookup, do_not_reverse_lookup=, for_fd, #local_address, #recv_nonblock, #remote_address
Methods inherited from IO
#<<, #_read_buf, #each, #each_byte, #eof?, #flush, #getc, #gets, #hash, open, pipe, popen, #pos, #pos=, #print, #printf, #puts, read, #read, #readchar, #readline, #readlines, #rewind, #seek, #ungetc, #write
Constructor Details
#initialize(path) ⇒ UNIXServer
Returns a new instance of UNIXServer.
524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 |
# File 'ext/enterprise_script_service/mruby/mrbgems/mruby-socket/mrblib/socket.rb', line 524 def initialize(path) fd = Socket._socket(Socket::AF_UNIX, Socket::SOCK_STREAM, 0) begin super(fd) Socket._bind(fd, Socket.pack_sockaddr_un(path)) self.listen(5) rescue => e IO._sysclose(fd) rescue nil raise e end if block_given? begin yield self ensure self.close rescue nil unless self.closed? end end end |
Instance Method Details
#accept ⇒ Object
544 545 546 547 548 549 550 551 552 |
# File 'ext/enterprise_script_service/mruby/mrbgems/mruby-socket/mrblib/socket.rb', line 544 def accept fd = self.sysaccept begin sock = UNIXSocket.for_fd(fd) rescue IO._sysclose(fd) rescue nil end sock end |
#accept_nonblock ⇒ Object
554 555 556 557 558 559 560 561 |
# File 'ext/enterprise_script_service/mruby/mrbgems/mruby-socket/mrblib/socket.rb', line 554 def accept_nonblock begin self._setnonblock(true) self.accept ensure self._setnonblock(false) end end |