Class: IPSocket
- Inherits:
-
BasicSocket
- Object
- IO
- BasicSocket
- IPSocket
- Defined in:
- mrbgems/mruby-socket/src/socket.c,
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
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from BasicSocket
#_is_socket=, #_recvfrom, #_setnonblock, #close, do_not_reverse_lookup, do_not_reverse_lookup=, for_fd, #getpeereid, #getpeername, #getsockname, #getsockopt, #initialize, #local_address, #recv, #recv_nonblock, #remote_address, #send, #setsockopt, #shutdown, #sysread, #sysseek, #syswrite
Methods inherited from IO
#<<, #_check_readable, #_read_buf, #close, #close_on_exec=, #close_on_exec?, #close_write, #closed?, #each, #each_byte, #eof?, #fileno, #flush, #getc, #gets, #hash, #initialize, #initialize_copy, #isatty, open, #pid, pipe, popen, #pos, #pos=, #print, #printf, #puts, read, #read, #readchar, #readline, #readlines, #rewind, #seek, #sync, #sync=, #sysread, #sysseek, #syswrite, #ungetc, #write
Constructor Details
This class inherits a constructor from BasicSocket
Class Method Details
.getaddress(host) ⇒ Object
212 213 214 |
# File 'mrbgems/mruby-socket/mrblib/socket.rb', line 212 def self.getaddress(host) Addrinfo.ip(host).ip_address end |
Instance Method Details
#addr ⇒ Object
216 217 218 |
# File 'mrbgems/mruby-socket/mrblib/socket.rb', line 216 def addr Addrinfo.new(self.getsockname)._to_array end |
#peeraddr ⇒ Object
220 221 222 |
# File 'mrbgems/mruby-socket/mrblib/socket.rb', line 220 def peeraddr Addrinfo.new(self.getpeername)._to_array end |
#recvfrom(maxlen, flags = 0) ⇒ Object
dummy
558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 |
# File 'mrbgems/mruby-socket/src/socket.c', line 558 static mrb_value mrb_ipsocket_recvfrom(mrb_state *mrb, mrb_value self) { struct sockaddr_storage ss; socklen_t socklen; mrb_value a, buf, pair; mrb_int flags, maxlen; ssize_t n; int fd; fd = socket_fd(mrb, self); flags = 0; mrb_get_args(mrb, "i|i", &maxlen, &flags); buf = mrb_str_buf_new(mrb, maxlen); socklen = sizeof(ss); n = recvfrom(fd, RSTRING_PTR(buf), (fsize_t)maxlen, (int)flags, (struct sockaddr *)&ss, &socklen); if (n == -1) { mrb_sys_fail(mrb, "recvfrom"); } mrb_str_resize(mrb, buf, (mrb_int)n); a = sa2addrlist(mrb, (struct sockaddr *)&ss, socklen); pair = mrb_ary_new_capa(mrb, 2); mrb_ary_push(mrb, pair, buf); mrb_ary_push(mrb, pair, a); return pair; } |