# File mrbgems/mruby-socket/mrblib/socket.rb, line 268 def initialize(host=nil, service) ai = Addrinfo.getaddrinfo(host, service, nil, nil, nil, Socket::AI_PASSIVE)[0] @init_with_fd = true super(Socket._socket(ai.afamily, Socket::SOCK_STREAM, 0), "r+") if Socket.const_defined?(:SO_REUSEADDR) self.setsockopt(Socket::SOL_SOCKET, Socket::SO_REUSEADDR, true) end Socket._bind(self.fileno, ai.to_sockaddr) listen(5) self end
# File mrbgems/mruby-socket/mrblib/socket.rb, line 280 def accept fd = self.sysaccept begin TCPSocket.new_with_prelude(proc { @init_with_fd = true }, fd, "r+") rescue IO._sysclose(fd) rescue nil raise end end
# File mrbgems/mruby-socket/mrblib/socket.rb, line 290 def accept_nonblock begin self._setnonblock(true) self.accept ensure self._setnonblock(false) end end