mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* ext/socket/ancdata.c (ancillary_inspect): show address family.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22182 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
8977fe1e36
commit
ecfea8e28e
2 changed files with 24 additions and 9 deletions
|
@ -1,3 +1,7 @@
|
|||
Mon Feb 9 21:48:59 2009 Tanaka Akira <akr@fsij.org>
|
||||
|
||||
* ext/socket/ancdata.c (ancillary_inspect): show address family.
|
||||
|
||||
Mon Feb 9 20:19:36 2009 Tanaka Akira <akr@fsij.org>
|
||||
|
||||
* ext/socket/basicsocket.c (bsock_getsockname): use sockaddr_storage.
|
||||
|
|
|
@ -48,6 +48,7 @@ cmsg_type_to_sym(int level, int cmsg_type)
|
|||
* - Socket::SOL_SOCKET, "SOL_SOCKET", "SOCKET", :SOL_SOCKET and :SOCKET
|
||||
* - Socket::IPPROTO_IP, "IP" and :IP
|
||||
* - Socket::IPPROTO_IPV6, "IPV6" and :IPV6
|
||||
* - Socket::IPPROTO_TCP, "TCP" and :TCP
|
||||
* - etc.
|
||||
*
|
||||
* _cmsg_type_ should be an integer, a string or a symbol.
|
||||
|
@ -59,8 +60,11 @@ cmsg_type_to_sym(int level, int cmsg_type)
|
|||
*
|
||||
* _cmsg_data_ should be a string.
|
||||
*
|
||||
* p Socket::AncillaryData.new(:IPV6, :PKTINFO, "")
|
||||
* #=> #<Socket::AncillaryData: IPV6 PKTINFO "">
|
||||
* p Socket::AncillaryData.new(:INET, :TCP, :NODELAY, "")'
|
||||
* #=> #<Socket::AncillaryData: AF_INET TCP NODELAY "">
|
||||
*
|
||||
* p Socket::AncillaryData.new(:INET6, :IPV6, :PKTINFO, "")
|
||||
* #=> #<Socket::AncillaryData: INET6 IPV6 PKTINFO "">
|
||||
*
|
||||
*/
|
||||
static VALUE
|
||||
|
@ -101,7 +105,7 @@ ancillary_family(VALUE self)
|
|||
* returns the socket family as an integer.
|
||||
*
|
||||
* p Socket::AncillaryData.new(:INET6, :IPV6, :PKTINFO, "").family
|
||||
* #=> 41
|
||||
* #=> 10
|
||||
*/
|
||||
static VALUE
|
||||
ancillary_family_m(VALUE self)
|
||||
|
@ -201,7 +205,7 @@ ancillary_s_int(VALUE klass, VALUE vfamily, VALUE vlevel, VALUE vtype, VALUE int
|
|||
* The size and endian is dependent on the host.
|
||||
*
|
||||
* ancdata = Socket::AncillaryData.int(:UNIX, :SOCKET, :RIGHTS, STDERR.fileno)
|
||||
* p ancdata.int => 2
|
||||
* p ancdata.int #=> 2
|
||||
*/
|
||||
static VALUE
|
||||
ancillary_int(VALUE self)
|
||||
|
@ -583,22 +587,29 @@ static VALUE
|
|||
ancillary_inspect(VALUE self)
|
||||
{
|
||||
VALUE ret;
|
||||
int level, type;
|
||||
int family, level, type;
|
||||
VALUE data;
|
||||
ID level_id;
|
||||
ID family_id, level_id;
|
||||
VALUE vtype;
|
||||
|
||||
family = ancillary_family(self);
|
||||
level = ancillary_level(self);
|
||||
type = ancillary_type(self);
|
||||
data = ancillary_data(self);
|
||||
|
||||
ret = rb_sprintf("#<%s: ", rb_obj_classname(self));
|
||||
|
||||
family_id = intern_family(family);
|
||||
if (family_id)
|
||||
rb_str_cat2(ret, rb_id2name(family_id));
|
||||
else
|
||||
rb_str_catf(ret, "family:%d", family);
|
||||
|
||||
level_id = intern_level(level);
|
||||
if (level_id)
|
||||
rb_str_cat2(ret, rb_id2name(level_id));
|
||||
rb_str_catf(ret, " %s", rb_id2name(level_id));
|
||||
else
|
||||
rb_str_catf(ret, "cmsg_level:%d", level);
|
||||
rb_str_catf(ret, " cmsg_level:%d", level);
|
||||
|
||||
vtype = cmsg_type_to_sym(level, type);
|
||||
if (SYMBOL_P(vtype))
|
||||
|
@ -870,7 +881,7 @@ bsock_sendmsg_internal(int argc, VALUE *argv, VALUE sock, int nonblock)
|
|||
* sendmsg can be used to implement send_io as follows:
|
||||
*
|
||||
* # use Socket::AncillaryData.
|
||||
* ancdata = Socket::AncillaryData.int(:SOCKET, :RIGHTS, io.fileno)
|
||||
* ancdata = Socket::AncillaryData.int(:UNIX, :SOCKET, :RIGHTS, io.fileno)
|
||||
* sock.sendmsg("a", 0, nil, ancdata)
|
||||
*
|
||||
* # use 3-element array.
|
||||
|
|
Loading…
Reference in a new issue