ÿØÿà JFIF    ÿÛ „ ( %!1!%*+...983,7(-.- PK<,]gs‚bb for_fd-c.rinu[U:RDoc::AnyMethod[iI" for_fd:ETI"BasicSocket::for_fd;TT: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"FReturns a socket object which contains the file descriptor, _fd_.;To:RDoc::Markup::BlankLineo:RDoc::Markup::Verbatim; [I"=# If invoked by inetd, STDIN/STDOUT/STDERR is a socket. ;TI".STDIN_SOCK = Socket.for_fd(STDIN.fileno) ;TI" p STDIN_SOCK.remote_address;T: @format0: @fileI"ext/socket/basicsocket.c;T:0@omit_headings_from_table_of_contents_below0I"+BasicSocket.for_fd(fd) => basicsocket ;T0[I" (p1);T@FI"BasicSocket;TcRDoc::NormalClass00PK<,]ޟjdo_not_reverse_lookup-c.rinu[U:RDoc::AnyMethod[iI"do_not_reverse_lookup:ETI"'BasicSocket::do_not_reverse_lookup;TT: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"0Gets the global do_not_reverse_lookup flag.;To:RDoc::Markup::BlankLineo:RDoc::Markup::Verbatim; [I"1BasicSocket.do_not_reverse_lookup #=> false;T: @format0: @fileI"ext/socket/basicsocket.c;T:0@omit_headings_from_table_of_contents_below0I"8BasicSocket.do_not_reverse_lookup => true or false ;T0[I"();T@FI"BasicSocket;TcRDoc::NormalClass00PK<,] recv-i.rinu[U:RDoc::AnyMethod[iI" recv:ETI"BasicSocket#recv;TF: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"Receives a message.;To:RDoc::Markup::BlankLineo; ; [I"8_maxlen_ is the maximum number of bytes to receive.;T@o; ; [I"?_flags_ should be a bitwise OR of Socket::MSG_* constants.;T@o; ; [I"H_outbuf_ will contain only the received data after the method call ;TI".even if it is not empty at the beginning.;T@o:RDoc::Markup::Verbatim; [ I"UNIXSocket.pair {|s1, s2| ;TI" s1.puts "Hello World" ;TI"3 p s2.recv(4) #=> "Hell" ;TI"3 p s2.recv(4, Socket::MSG_PEEK) #=> "o Wo" ;TI"3 p s2.recv(4) #=> "o Wo" ;TI"4 p s2.recv(10) #=> "rld\n" ;TI"};T: @format0: @fileI"ext/socket/basicsocket.c;T:0@omit_headings_from_table_of_contents_below0I"9basicsocket.recv(maxlen[, flags[, outbuf]]) => mesg ;T0[I" (*args);T@"FI"BasicSocket;TcRDoc::NormalClass00PK<,]"UUdo_not_reverse_lookup%3d-i.rinu[U:RDoc::AnyMethod[iI"do_not_reverse_lookup=:ETI"'BasicSocket#do_not_reverse_lookup=;TF: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I":Sets the do_not_reverse_lookup flag of _basicsocket_.;To:RDoc::Markup::BlankLineo:RDoc::Markup::Verbatim; [ I"5TCPSocket.open("www.ruby-lang.org", 80) {|sock| ;TI"3 p sock.do_not_reverse_lookup #=> true ;TI"b p sock.peeraddr #=> ["AF_INET", 80, "221.186.184.68", "221.186.184.68"] ;TI"* sock.do_not_reverse_lookup = false ;TI"h p sock.peeraddr #=> ["AF_INET", 80, "carbon.ruby-lang.org", "54.163.249.195"] ;TI"};T: @format0: @fileI"ext/socket/basicsocket.c;T:0@omit_headings_from_table_of_contents_below0I".basicsocket.do_not_reverse_lookup = bool ;T0[I" (p1);T@FI"BasicSocket;TcRDoc::NormalClass00PK<,]3Xttgetpeereid-i.rinu[U:RDoc::AnyMethod[iI"getpeereid:ETI"BasicSocket#getpeereid;TF: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"@Returns the user and group on the peer of the UNIX socket. ;TI"^The result is a two element array which contains the effective uid and the effective gid.;To:RDoc::Markup::BlankLineo:RDoc::Markup::Verbatim; [I"/Socket.unix_server_loop("/tmp/sock") {|s| ;TI" begin ;TI"# euid, egid = s.getpeereid ;TI" ;TI"8 # Check the connected client is myself or not. ;TI"% next if euid != Process.uid ;TI" ;TI"+ # do something about my resource. ;TI" ;TI" ensure ;TI" s.close ;TI" end ;TI"};T: @format0: @fileI"ext/socket/basicsocket.c;T:0@omit_headings_from_table_of_contents_below0I",basicsocket.getpeereid => [euid, egid] ;T0[I"();T@FI"BasicSocket;TcRDoc::NormalClass00PK<,]Ok// sendmsg-i.rinu[U:RDoc::AnyMethod[iI" sendmsg:ETI"BasicSocket#sendmsg;TF: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"Msendmsg sends a message using sendmsg(2) system call in blocking manner.;To:RDoc::Markup::BlankLineo; ; [I" _mesg_ is a string to send.;T@o; ; [I"F_flags_ is bitwise OR of MSG_* constants such as Socket::MSG_OOB.;T@o; ; [I"Q_dest_sockaddr_ is a destination socket address for connection-less socket. ;TI"EIt should be a sockaddr such as a result of Socket.sockaddr_in. ;TI"(An Addrinfo object can be used too.;T@o; ; [ I"-_controls_ is a list of ancillary data. ;TI"BThe element of _controls_ should be Socket::AncillaryData or ;TI"3-elements array. ;TI"HThe 3-element array should contains cmsg_level, cmsg_type and data.;T@o; ; [I"WThe return value, _numbytes_sent_ is an integer which is the number of bytes sent.;T@o; ; [I"9sendmsg can be used to implement send_io as follows:;T@o:RDoc::Markup::Verbatim; [ I""# use Socket::AncillaryData. ;TI"Mancdata = Socket::AncillaryData.int(:UNIX, :SOCKET, :RIGHTS, io.fileno) ;TI"(sock.sendmsg("a", 0, nil, ancdata) ;TI" ;TI"# use 3-element array. ;TI":ancdata = [:SOCKET, :RIGHTS, [io.fileno].pack("i!")] ;TI"(sock.sendmsg("\0", 0, nil, ancdata);T: @format0: @fileI"ext/socket/lib/socket.rb;T:0@omit_headings_from_table_of_contents_below0I"Wbasicsocket.sendmsg(mesg, flags=0, dest_sockaddr=nil, *controls) => numbytes_sent ;T0[I"6(mesg, flags = 0, dest_sockaddr = nil, *controls);T@/FI"BasicSocket;TcRDoc::NormalClass00PK<,]-3close_write-i.rinu[U:RDoc::AnyMethod[iI"close_write:ETI"BasicSocket#close_write;TF: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"8Disallows further write using shutdown system call.;To:RDoc::Markup::BlankLineo:RDoc::Markup::Verbatim; [ I"UNIXSocket.pair {|s1, s2| ;TI" s1.print "ping" ;TI" s1.close_write ;TI"# p s2.read #=> "ping" ;TI" s2.print "pong" ;TI" s2.close ;TI"# p s1.read #=> "pong" ;TI"};T: @format0: @fileI"ext/socket/basicsocket.c;T:0@omit_headings_from_table_of_contents_below0I"$basicsocket.close_write => nil ;T0[I"();T@FI"BasicSocket;TcRDoc::NormalClass00PK<,] recv_nonblock-i.rinu[U:RDoc::AnyMethod[iI"recv_nonblock:ETI"BasicSocket#recv_nonblock;TF: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [ I"IReceives up to _maxlen_ bytes from +socket+ using recvfrom(2) after ;TI";O_NONBLOCK is set for the underlying file descriptor. ;TI"4_flags_ is zero or more of the +MSG_+ options. ;TI".The result, _mesg_, is the data received.;To:RDoc::Markup::BlankLineo; ; [I">When recvfrom(2) returns 0, Socket#recv_nonblock returns ;TI"an empty string as data. ;TI"MThe meaning depends on the socket: EOF on TCP, empty packet on UDP, etc.;T@S:RDoc::Markup::Heading: leveli: textI"Parameters;To:RDoc::Markup::List: @type: BULLET: @items[ o:RDoc::Markup::ListItem: @label0; [o; ; [I">+maxlen+ - the number of bytes to receive from the socket;To;;0; [o; ; [I"1+flags+ - zero or more of the +MSG_+ options;To;;0; [o; ; [I"&+buf+ - destination String buffer;To;;0; [o; ; [I"<+options+ - keyword hash, supporting `exception: false`;T@S; ; i;I" Example;To:RDoc::Markup::Verbatim; [I"*serv = TCPServer.new("127.0.0.1", 0) ;TI"&af, port, host, addr = serv.addr ;TI"#c = TCPSocket.new(addr, port) ;TI"s = serv.accept ;TI"c.send "aaa", 0 ;TI"$begin # emulate blocking recv. ;TI"' p s.recv_nonblock(10) #=> "aaa" ;TI"rescue IO::WaitReadable ;TI" IO.select([s]) ;TI" retry ;TI" end ;T: @format0o; ; [I"PRefer to Socket#recvfrom for the exceptions that may be thrown if the call ;TI"to _recv_nonblock_ fails.;T@o; ; [I"YBasicSocket#recv_nonblock may raise any error corresponding to recvfrom(2) failure, ;TI""including Errno::EWOULDBLOCK.;T@o; ; [I">If the exception is Errno::EWOULDBLOCK or Errno::EAGAIN, ;TI")it is extended by IO::WaitReadable. ;TI"YSo IO::WaitReadable can be used to rescue the exceptions for retrying recv_nonblock.;T@o; ; [I"OBy specifying a keyword argument _exception_ to +false+, you can indicate ;TI"Lthat recv_nonblock should not raise an IO::WaitReadable exception, but ;TI"0return the symbol +:wait_readable+ instead.;T@S; ; i;I"See;To;;;;[o;;0; [o; ; [I"Socket#recvfrom;T: @fileI"ext/socket/lib/socket.rb;T:0@omit_headings_from_table_of_contents_below0I"Nbasicsocket.recv_nonblock(maxlen [, flags [, buf [, options ]]]) => mesg ;T0[I"0(len, flag = 0, str = nil, exception: true);T@YFI"BasicSocket;TcRDoc::NormalClass00PK<,]!rVVdo_not_reverse_lookup-i.rinu[U:RDoc::AnyMethod[iI"do_not_reverse_lookup:ETI"&BasicSocket#do_not_reverse_lookup;TF: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I":Gets the do_not_reverse_lookup flag of _basicsocket_.;To:RDoc::Markup::BlankLineo:RDoc::Markup::Verbatim; [I"require 'socket' ;TI" ;TI"/BasicSocket.do_not_reverse_lookup = false ;TI"5TCPSocket.open("www.ruby-lang.org", 80) {|sock| ;TI"3 p sock.do_not_reverse_lookup #=> false ;TI"} ;TI".BasicSocket.do_not_reverse_lookup = true ;TI"5TCPSocket.open("www.ruby-lang.org", 80) {|sock| ;TI"2 p sock.do_not_reverse_lookup #=> true ;TI"};T: @format0: @fileI"ext/socket/basicsocket.c;T:0@omit_headings_from_table_of_contents_below0I"8basicsocket.do_not_reverse_lookup => true or false ;T0[I"();T@FI"BasicSocket;TcRDoc::NormalClass00PK<,] i8getsockname-i.rinu[U:RDoc::AnyMethod[iI"getsockname:ETI"BasicSocket#getsockname;TF: privateo:RDoc::Markup::Document: @parts[ o:RDoc::Markup::Paragraph; [I"BReturns the local address of the socket as a sockaddr string.;To:RDoc::Markup::BlankLineo:RDoc::Markup::Verbatim; [I"0TCPServer.open("127.0.0.1", 15120) {|serv| ;TI"^ p serv.getsockname #=> "\x02\x00;\x10\x7F\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00" ;TI"} ;T: @format0o; ; [I"=If Addrinfo object is preferred over the binary string, ;TI"#use BasicSocket#local_address.;T: @fileI"ext/socket/basicsocket.c;T:0@omit_headings_from_table_of_contents_below0I")basicsocket.getsockname => sockaddr ;T0[I"();T@FI"BasicSocket;TcRDoc::NormalClass00PK<,]+_ڂcdesc-BasicSocket.rinu[U:RDoc::NormalClass[iI"BasicSocket:ET@I"IO;To:RDoc::Markup::Document: @parts[o;;[o:RDoc::Markup::Paragraph;[I"?BasicSocket is the super class for all the Socket classes.;T: @fileI"ext/socket/basicsocket.c;T:0@omit_headings_from_table_of_contents_below0o;;[; I"ext/socket/lib/socket.rb;T; 0; 0; 0[[[[[I" class;T[[: public[[:protected[[: private[[I"do_not_reverse_lookup;TI"ext/socket/basicsocket.c;T[I"do_not_reverse_lookup=;T@#[I" for_fd;T@#[I" instance;T[[; [[; [[;[[I"close_read;T@#[I"close_write;T@#[I"connect_address;TI"ext/socket/lib/socket.rb;T[I"do_not_reverse_lookup;T@#[I"do_not_reverse_lookup=;T@#[I"getpeereid;T@#[I"getpeername;T@#[I"getsockname;T@#[I"getsockopt;T@#[I"local_address;T@#[I" recv;T@#[I"recv_nonblock;T@7[I" recvmsg;T@7[I"recvmsg_nonblock;T@7[I"remote_address;T@#[I" send;T@#[I" sendmsg;T@7[I"sendmsg_nonblock;T@7[I"setsockopt;T@#[I" shutdown;T@#[[U:RDoc::Context::Section[i0o;;[; 0; 0[I"ext/socket/basicsocket.c;TI"ext/socket/lib/socket.rb;T@cRDoc::TopLevelPK<,]{i shutdown-i.rinu[U:RDoc::AnyMethod[iI" shutdown:ETI"BasicSocket#shutdown;TF: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"#Calls shutdown(2) system call.;To:RDoc::Markup::BlankLineo; ; [I"8s.shutdown(Socket::SHUT_RD) disallows further read.;T@o; ; [I"9s.shutdown(Socket::SHUT_WR) disallows further write.;T@o; ; [I"Ds.shutdown(Socket::SHUT_RDWR) disallows further read and write.;T@o; ; [I"#_how_ can be symbol or string:;To:RDoc::Markup::List: @type: BULLET: @items[o:RDoc::Markup::ListItem: @label0; [o; ; [I"G:RD, :SHUT_RD, "RD" and "SHUT_RD" are accepted as Socket::SHUT_RD.;To;;0; [o; ; [I"G:WR, :SHUT_WR, "WR" and "SHUT_WR" are accepted as Socket::SHUT_WR.;To;;0; [ o; ; [I"Q:RDWR, :SHUT_RDWR, "RDWR" and "SHUT_RDWR" are accepted as Socket::SHUT_RDWR.;T@o; ; [I"UNIXSocket.pair {|s1, s2|;To:RDoc::Markup::Verbatim; [ I"s1.puts "ping" ;TI"s1.shutdown(:WR) ;TI"%p s2.read #=> "ping\n" ;TI"s2.puts "pong" ;TI"s2.close ;TI"%p s1.read #=> "pong\n" ;T: @format0o; ; [I"};T: @fileI"ext/socket/basicsocket.c;T:0@omit_headings_from_table_of_contents_below0I"&basicsocket.shutdown([how]) => 0 ;T0[I"(p1 = v1);T@:FI"BasicSocket;TcRDoc::NormalClass00PK<,].jMlocal_address-i.rinu[U:RDoc::AnyMethod[iI"local_address:ETI"BasicSocket#local_address;TF: privateo:RDoc::Markup::Document: @parts[ o:RDoc::Markup::Paragraph; [I"JReturns an Addrinfo object for local address obtained by getsockname.;To:RDoc::Markup::BlankLineo; ; [I"0Note that addrinfo.protocol is filled by 0.;T@o:RDoc::Markup::Verbatim; [ I"2TCPSocket.open("www.ruby-lang.org", 80) {|s| ;TI"B p s.local_address #=> # ;TI"} ;TI" ;TI"/TCPServer.open("127.0.0.1", 1512) {|serv| ;TI"@ p serv.local_address #=> # ;TI"};T: @format0: @fileI"ext/socket/basicsocket.c;T:0@omit_headings_from_table_of_contents_below0I"%bsock.local_address => addrinfo ;T0[I"();T@FI"BasicSocket;TcRDoc::NormalClass00PK<,]   send-i.rinu[U:RDoc::AnyMethod[iI" send:ETI"BasicSocket#send;TF: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"#send _mesg_ via _basicsocket_.;To:RDoc::Markup::BlankLineo; ; [I"_mesg_ should be a string.;T@o; ; [I"?_flags_ should be a bitwise OR of Socket::MSG_* constants.;T@o; ; [I"G_dest_sockaddr_ should be a packed sockaddr string or an addrinfo.;T@o:RDoc::Markup::Verbatim; [ I"*TCPSocket.open("localhost", 80) {|s| ;TI"* s.send "GET / HTTP/1.0\r\n\r\n", 0 ;TI" p s.read ;TI"};T: @format0: @fileI"ext/socket/basicsocket.c;T:0@omit_headings_from_table_of_contents_below0I"Fbasicsocket.send(mesg, flags [, dest_sockaddr]) => numbytes_sent ;T0[I"(p1, p2, p3 = v3);T@FI"BasicSocket;TcRDoc::NormalClass00PK<,]N"!!close_read-i.rinu[U:RDoc::AnyMethod[iI"close_read:ETI"BasicSocket#close_read;TF: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"7Disallows further read using shutdown system call.;To:RDoc::Markup::BlankLineo:RDoc::Markup::Verbatim; [I"s1, s2 = UNIXSocket.pair ;TI"s1.close_read ;TI"+s2.puts #=> Broken pipe (Errno::EPIPE);T: @format0: @fileI"ext/socket/basicsocket.c;T:0@omit_headings_from_table_of_contents_below0I"#basicsocket.close_read => nil ;T0[I"();T@FI"BasicSocket;TcRDoc::NormalClass00PK<,]!՘recvmsg_nonblock-i.rinu[U:RDoc::AnyMethod[iI"recvmsg_nonblock:ETI"!BasicSocket#recvmsg_nonblock;TF: privateo:RDoc::Markup::Document: @parts[ o:RDoc::Markup::Paragraph; [I"Trecvmsg receives a message using recvmsg(2) system call in non-blocking manner.;To:RDoc::Markup::BlankLineo; ; [I"*It is similar to BasicSocket#recvmsg ;TI"9but non-blocking flag is set before the system call ;TI"*and it doesn't retry the system call.;T@o; ; [I"OBy specifying a keyword argument _exception_ to +false+, you can indicate ;TI"Othat recvmsg_nonblock should not raise an IO::WaitReadable exception, but ;TI"0return the symbol +:wait_readable+ instead.;T: @fileI"ext/socket/lib/socket.rb;T:0@omit_headings_from_table_of_contents_below0I"basicsocket.recvmsg_nonblock(maxdatalen=nil, flags=0, maxcontrollen=nil, opts={}) => [data, sender_addrinfo, rflags, *controls] ;T0[I"L(dlen = nil, flags = 0, clen = nil, scm_rights: false, exception: true);T@FI"BasicSocket;TcRDoc::NormalClass00PK<,]TָRsendmsg_nonblock-i.rinu[U:RDoc::AnyMethod[iI"sendmsg_nonblock:ETI"!BasicSocket#sendmsg_nonblock;TF: privateo:RDoc::Markup::Document: @parts[ o:RDoc::Markup::Paragraph; [I"Zsendmsg_nonblock sends a message using sendmsg(2) system call in non-blocking manner.;To:RDoc::Markup::BlankLineo; ; [I"*It is similar to BasicSocket#sendmsg ;TI"=but the non-blocking flag is set before the system call ;TI"*and it doesn't retry the system call.;T@o; ; [I"OBy specifying a keyword argument _exception_ to +false+, you can indicate ;TI"Othat sendmsg_nonblock should not raise an IO::WaitWritable exception, but ;TI"0return the symbol +:wait_writable+ instead.;T: @fileI"ext/socket/lib/socket.rb;T:0@omit_headings_from_table_of_contents_below0I"ibasicsocket.sendmsg_nonblock(mesg, flags=0, dest_sockaddr=nil, *controls, opts={}) => numbytes_sent ;T0[I"G(mesg, flags = 0, dest_sockaddr = nil, *controls, exception: true);T@FI"BasicSocket;TcRDoc::NormalClass00PK<,].,))connect_address-i.rinu[U:RDoc::AnyMethod[iI"connect_address:ETI" BasicSocket#connect_address;TF: privateo:RDoc::Markup::Document: @parts[ o:RDoc::Markup::Paragraph; [I"PReturns an address of the socket suitable for connect in the local machine.;To:RDoc::Markup::BlankLineo; ; [I"JThis method returns _self_.local_address, except following condition.;T@o:RDoc::Markup::List: @type: BULLET: @items[o:RDoc::Markup::ListItem: @label0; [o; ; [I"YIPv4 unspecified address (0.0.0.0) is replaced by IPv4 loopback address (127.0.0.1).;To;;0; [o; ; [I"NIPv6 unspecified address (::) is replaced by IPv6 loopback address (::1).;T@o; ; [I"NIf the local address is not suitable for connect, SocketError is raised. ;TI"HIPv4 and IPv6 address which port is 0 is not suitable for connect. ;TI"FUnix domain socket which has no path is not suitable for connect.;T@o:RDoc::Markup::Verbatim; [ I"/Addrinfo.tcp("0.0.0.0", 0).listen {|serv| ;TI"C p serv.connect_address #=> # ;TI") serv.connect_address.connect {|c| ;TI" s, _ = serv.accept ;TI"7 p [c, s] #=> [#, #] ;TI" } ;TI"};T: @format0: @fileI"ext/socket/lib/socket.rb;T:0@omit_headings_from_table_of_contents_below000[I"();T@,FI"BasicSocket;TcRDoc::NormalClass00PK<,]qssdo_not_reverse_lookup%3d-c.rinu[U:RDoc::AnyMethod[iI"do_not_reverse_lookup=:ETI"(BasicSocket::do_not_reverse_lookup=;TT: privateo:RDoc::Markup::Document: @parts[ o:RDoc::Markup::Paragraph; [I"0Sets the global do_not_reverse_lookup flag.;To:RDoc::Markup::BlankLineo; ; [I"QThe flag is used for initial value of do_not_reverse_lookup for each socket.;T@o:RDoc::Markup::Verbatim; [ I")s1 = TCPSocket.new("localhost", 80) ;TI"9p s1.do_not_reverse_lookup #=> true ;TI"/BasicSocket.do_not_reverse_lookup = false ;TI")s2 = TCPSocket.new("localhost", 80) ;TI":p s2.do_not_reverse_lookup #=> false ;TI"8p s1.do_not_reverse_lookup #=> true;T: @format0: @fileI"ext/socket/basicsocket.c;T:0@omit_headings_from_table_of_contents_below0I".BasicSocket.do_not_reverse_lookup = bool ;T0[I" (p1);T@FI"BasicSocket;TcRDoc::NormalClass00PK<,]RYccremote_address-i.rinu[U:RDoc::AnyMethod[iI"remote_address:ETI"BasicSocket#remote_address;TF: privateo:RDoc::Markup::Document: @parts[ o:RDoc::Markup::Paragraph; [I"KReturns an Addrinfo object for remote address obtained by getpeername.;To:RDoc::Markup::BlankLineo; ; [I"0Note that addrinfo.protocol is filled by 0.;T@o:RDoc::Markup::Verbatim; [I"2TCPSocket.open("www.ruby-lang.org", 80) {|s| ;TI"A p s.remote_address #=> # ;TI"} ;TI" ;TI"/TCPServer.open("127.0.0.1", 1728) {|serv| ;TI", c = TCPSocket.new("127.0.0.1", 1728) ;TI" s = serv.accept ;TI"? p s.remote_address #=> # ;TI"};T: @format0: @fileI"ext/socket/basicsocket.c;T:0@omit_headings_from_table_of_contents_below0I"&bsock.remote_address => addrinfo ;T0[I"();T@FI"BasicSocket;TcRDoc::NormalClass00PK<,]_4F- - setsockopt-i.rinu[U:RDoc::AnyMethod[iI"setsockopt:ETI"BasicSocket#setsockopt;TF: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"LSets a socket option. These are protocol and system specific, see your ;TI",local system documentation for details.;To:RDoc::Markup::BlankLineS:RDoc::Markup::Heading: leveli: textI"Parameters;To:RDoc::Markup::List: @type: BULLET: @items[ o:RDoc::Markup::ListItem: @label0; [o; ; [ I"F+level+ is an integer, usually one of the SOL_ constants such as ;TI".Socket::SOL_SOCKET, or a protocol level. ;TI"FA string or symbol of the name, possibly without prefix, is also ;TI"accepted.;To;;0; [o; ; [ I"E+optname+ is an integer, usually one of the SO_ constants, such ;TI"as Socket::SO_REUSEADDR. ;TI"FA string or symbol of the name, possibly without prefix, is also ;TI"accepted.;To;;0; [o; ; [I"I+optval+ is the value of the option, it is passed to the underlying ;TI"Isetsockopt() as a pointer to a certain number of bytes. How this is ;TI"done depends on the type:;To;;;;[o;;0; [o; ; [I"GInteger: value is assigned to an int, and a pointer to the int is ;TI"(passed, with length of sizeof(int).;To;;0; [o; ; [I"Itrue or false: 1 or 0 (respectively) is assigned to an int, and the ;TI"Hint is passed as for an Integer. Note that +false+ must be passed, ;TI"not +nil+.;To;;0; [o; ; [I"BString: the string's data and length is passed to the socket.;To;;0; [o; ; [I"4+socketoption+ is an instance of Socket::Option;T@S; ; i;I" Examples;T@o; ; [I"HSome socket options are integers with boolean values, in this case ;TI"+#setsockopt could be called like this:;To:RDoc::Markup::Verbatim; [I"0sock.setsockopt(:SOCKET, :REUSEADDR, true) ;TI"Dsock.setsockopt(Socket::SOL_SOCKET,Socket::SO_REUSEADDR, true) ;TI"Lsock.setsockopt(Socket::Option.bool(:INET, :SOCKET, :REUSEADDR, true)) ;T: @format0o; ; [I"HSome socket options are integers with numeric values, in this case ;TI"+#setsockopt could be called like this:;To;; [I"%sock.setsockopt(:IP, :TTL, 255) ;TI">sock.setsockopt(Socket::IPPROTO_IP, Socket::IP_TTL, 255) ;TI"@sock.setsockopt(Socket::Option.int(:INET, :IP, :TTL, 255)) ;T;0o; ; [I"NOption values may be structs. Passing them can be complex as it involves ;TI"Kexamining your system headers to determine the correct definition. An ;TI"Mexample is an +ip_mreq+, which may be defined in your system headers as:;To;; [ I"struct ip_mreq { ;TI"& struct in_addr imr_multiaddr; ;TI"& struct in_addr imr_interface; ;TI"}; ;T;0o; ; [I"8In this case #setsockopt could be called like this:;To;; [I"/optval = IPAddr.new("224.0.0.251").hton + ;TI"C IPAddr.new(Socket::INADDR_ANY, Socket::AF_INET).hton ;TI"Ksock.setsockopt(Socket::IPPROTO_IP, Socket::IP_ADD_MEMBERSHIP, optval);T;0: @fileI"ext/socket/basicsocket.c;T:0@omit_headings_from_table_of_contents_below0I"Asetsockopt(level, optname, optval) setsockopt(socketoption) ;T0[I"(p1, p2, p3);T@kFI"BasicSocket;TcRDoc::NormalClass00PK<,]-* getsockopt-i.rinu[U:RDoc::AnyMethod[iI"getsockopt:ETI"BasicSocket#getsockopt;TF: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"LGets a socket option. These are protocol and system specific, see your ;TI"Glocal system documentation for details. The option is returned as ;TI"a Socket::Option object.;To:RDoc::Markup::BlankLineS:RDoc::Markup::Heading: leveli: textI"Parameters;To:RDoc::Markup::List: @type: BULLET: @items[o:RDoc::Markup::ListItem: @label0; [o; ; [ I"F+level+ is an integer, usually one of the SOL_ constants such as ;TI".Socket::SOL_SOCKET, or a protocol level. ;TI"FA string or symbol of the name, possibly without prefix, is also ;TI"accepted.;To;;0; [o; ; [ I"E+optname+ is an integer, usually one of the SO_ constants, such ;TI"as Socket::SO_REUSEADDR. ;TI"FA string or symbol of the name, possibly without prefix, is also ;TI"accepted.;T@S; ; i;I" Examples;T@o; ; [I"HSome socket options are integers with boolean values, in this case ;TI"+#getsockopt could be called like this:;T@o:RDoc::Markup::Verbatim; [ I";reuseaddr = sock.getsockopt(:SOCKET, :REUSEADDR).bool ;TI" ;TI"Goptval = sock.getsockopt(Socket::SOL_SOCKET,Socket::SO_REUSEADDR) ;TI" optval = optval.unpack "i" ;TI"/reuseaddr = optval[0] == 0 ? false : true ;T: @format0o; ; [I"HSome socket options are integers with numeric values, in this case ;TI"+#getsockopt could be called like this:;T@o;; [ I",ipttl = sock.getsockopt(:IP, :TTL).int ;TI" ;TI"Boptval = sock.getsockopt(Socket::IPPROTO_IP, Socket::IP_TTL) ;TI"!ipttl = optval.unpack1("i") ;T;0o; ; [ I"OOption values may be structs. Decoding them can be complex as it involves ;TI"Kexamining your system headers to determine the correct definition. An ;TI"Oexample is a +struct linger+, which may be defined in your system headers ;TI"as:;To;; [ I"struct linger { ;TI" int l_onoff; ;TI" int l_linger; ;TI"}; ;T;0o; ; [I"8In this case #getsockopt could be called like this:;T@o;; [ I".# Socket::Option knows linger structure. ;TI">onoff, linger = sock.getsockopt(:SOCKET, :LINGER).linger ;TI" ;TI"Foptval = sock.getsockopt(Socket::SOL_SOCKET, Socket::SO_LINGER) ;TI"(onoff, linger = optval.unpack "ii" ;TI"&onoff = onoff == 0 ? false : true;T;0: @fileI"ext/socket/basicsocket.c;T:0@omit_headings_from_table_of_contents_below0I"0getsockopt(level, optname) => socketoption ;T0[I" (p1, p2);T@SFI"BasicSocket;TcRDoc::NormalClass00PK<,] recvmsg-i.rinu[U:RDoc::AnyMethod[iI" recvmsg:ETI"BasicSocket#recvmsg;TF: privateo:RDoc::Markup::Document: @parts[#o:RDoc::Markup::Paragraph; [I"Precvmsg receives a message using recvmsg(2) system call in blocking manner.;To:RDoc::Markup::BlankLineo; ; [I";_maxmesglen_ is the maximum length of mesg to receive.;T@o; ; [I"G_flags_ is bitwise OR of MSG_* constants such as Socket::MSG_PEEK.;T@o; ; [I"S_maxcontrollen_ is the maximum length of controls (ancillary data) to receive.;T@o; ; [I"_opts_ is option hash. ;TI"4Currently :scm_rights=>bool is the only option.;T@o; ; [ I"W:scm_rights option specifies that application expects SCM_RIGHTS control message. ;TI"YIf the value is nil or false, application don't expects SCM_RIGHTS control message. ;TI"KIn this case, recvmsg closes the passed file descriptors immediately. ;TI""This is the default behavior.;T@o; ; [I"dIf :scm_rights value is neither nil nor false, application expects SCM_RIGHTS control message. ;TI"LIn this case, recvmsg creates IO objects for each file descriptors for ;TI".Socket::AncillaryData#unix_rights method.;T@o; ; [I"*The return value is 4-elements array.;T@o; ; [I"0_mesg_ is a string of the received message.;T@o; ; [I"N_sender_addrinfo_ is a sender socket address for connection-less socket. ;TI"It is an Addrinfo object. ;TI"WFor connection-oriented socket such as TCP, sender_addrinfo is platform dependent.;T@o; ; [I"s_rflags_ is a flags on the received message which is bitwise OR of MSG_* constants such as Socket::MSG_TRUNC. ;TI"LIt will be nil if the system uses 4.3BSD style old recvmsg system call.;T@o; ; [I"]_controls_ is ancillary data which is an array of Socket::AncillaryData objects such as:;T@o:RDoc::Markup::Verbatim; [I"7# ;T: @format0o; ; [ I"2_maxmesglen_ and _maxcontrollen_ can be nil. ;TI"PIn that case, the buffer will be grown until the message is not truncated. ;TI"#Internally, MSG_PEEK is used. ;TI";Buffer full and MSG_CTRUNC are checked for truncation.;T@o; ; [I"9recvmsg can be used to implement recv_io as follows:;T@o; ; [ I"Pmesg, sender_sockaddr, rflags, *controls = sock.recvmsg(:scm_rights=>true) ;TI"controls.each {|ancdata| ;TI"- if ancdata.cmsg_is?(:SOCKET, :RIGHTS) ;TI"' return ancdata.unix_rights[0] ;TI" end ;TI"};T; 0: @fileI"ext/socket/lib/socket.rb;T:0@omit_headings_from_table_of_contents_below0I"|basicsocket.recvmsg(maxmesglen=nil, flags=0, maxcontrollen=nil, opts={}) => [mesg, sender_addrinfo, rflags, *controls] ;T0[I";(dlen = nil, flags = 0, clen = nil, scm_rights: false);T@MFI"BasicSocket;TcRDoc::NormalClass00PK<,]Oagetpeername-i.rinu[U:RDoc::AnyMethod[iI"getpeername:ETI"BasicSocket#getpeername;TF: privateo:RDoc::Markup::Document: @parts[ o:RDoc::Markup::Paragraph; [I"CReturns the remote address of the socket as a sockaddr string.;To:RDoc::Markup::BlankLineo:RDoc::Markup::Verbatim; [ I"/TCPServer.open("127.0.0.1", 1440) {|serv| ;TI", c = TCPSocket.new("127.0.0.1", 1440) ;TI" s = serv.accept ;TI"[ p s.getpeername #=> "\x02\x00\x82u\x7F\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00" ;TI"} ;T: @format0o; ; [I"=If Addrinfo object is preferred over the binary string, ;TI"$use BasicSocket#remote_address.;T: @fileI"ext/socket/basicsocket.c;T:0@omit_headings_from_table_of_contents_below0I")basicsocket.getpeername => sockaddr ;T0[I"();T@FI"BasicSocket;TcRDoc::NormalClass00PK<,]gs‚bb for_fd-c.rinu[PK<,]ޟjdo_not_reverse_lookup-c.rinu[PK<,] recv-i.rinu[PK<,]"UU do_not_reverse_lookup%3d-i.rinu[PK<,]3Xtt getpeereid-i.rinu[PK<,]Ok// ksendmsg-i.rinu[PK<,]-3close_write-i.rinu[PK<,] recv_nonblock-i.rinu[PK<,]!rVVt#do_not_reverse_lookup-i.rinu[PK<,] i8'getsockname-i.rinu[PK<,]+_ڂ-*cdesc-BasicSocket.rinu[PK<,]{i .shutdown-i.rinu[PK<,].jM,4local_address-i.rinu[PK<,]   7send-i.rinu[PK<,]N"!!:close_read-i.rinu[PK<,]!՘-=recvmsg_nonblock-i.rinu[PK<,]TָRSAsendmsg_nonblock-i.rinu[PK<,].,))aEconnect_address-i.rinu[PK<,]qssJdo_not_reverse_lookup%3d-c.rinu[PK<,]RYccNremote_address-i.rinu[PK<,]_4F- - 4Rsetsockopt-i.rinu[PK<,]-* ^getsockopt-i.rinu[PK<,] hrecvmsg-i.rinu[PK<,]Oasgetpeername-i.rinu[PK w