Class: TCPSocket
- Defined in:
- ext/enterprise_script_service/mruby/mrbgems/mruby-socket/mrblib/socket.rb
Direct Known Subclasses
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
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(host, service, local_host = nil, local_service = nil) ⇒ TCPSocket
constructor
A new instance of TCPSocket.
Methods inherited from IPSocket
#addr, getaddress, #peeraddr, #recvfrom
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(host, service, local_host = nil, local_service = nil) ⇒ TCPSocket
Returns a new instance of TCPSocket.
231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 |
# File 'ext/enterprise_script_service/mruby/mrbgems/mruby-socket/mrblib/socket.rb', line 231 def initialize(host, service, local_host=nil, local_service=nil) if @init_with_fd super(host, service) else s = nil e = SocketError Addrinfo.foreach(host, service) { |ai| begin s = Socket._socket(ai.afamily, Socket::SOCK_STREAM, 0) if local_host or local_service local_host ||= (ai.afamily == Socket::AF_INET) ? "0.0.0.0" : "::" local_service ||= "0" bi = Addrinfo.getaddrinfo(local_host, local_service, ai.afamily, ai.socktype)[0] Socket._bind(s, bi.to_sockaddr) end Socket._connect(s, ai.to_sockaddr) super(s, "r+") return rescue => e0 e = e0 end } raise e end end |
Class Method Details
.new_with_prelude(pre, *args) ⇒ Object
257 258 259 260 261 262 |
# File 'ext/enterprise_script_service/mruby/mrbgems/mruby-socket/mrblib/socket.rb', line 257 def self.new_with_prelude pre, *args o = self._allocate o.instance_eval(&pre) o.initialize(*args) o end |