Skip to content

Loading…

implemented getaddrinfo addr method. #10

Closed
wants to merge 5 commits into from

2 participants

@matsumoto-r
UV::getaddrinfo("api.twitter.com", "http") do |x, a|
  if a
    puts "addr: #{a.addr}"  #=>  addr: 199.59.150.41
  end
end

UV::run()
@mattn
Owner

addrオブジェクトはUV:Ip4Addrオブジェクトにして、to_sにアドレス形式を出す方式にしようと思っていたので(addrをそのままbind等に渡せるように)、少し検討させて下さい。

@matsumoto-r

了解しました。

@mattn
Owner

最新でaddrinfoを実装したので、すみませんが閉じます。

@mattn mattn closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Dec 31, 2012
  1. @matsumoto-r
  2. @matsumoto-r

    fix name conflict

    matsumoto-r committed
Commits on Jan 4, 2013
  1. @matsumoto-r
  2. @matsumoto-r

    fix name conflict

    matsumoto-r committed
  3. @matsumoto-r

    Merge branch 'implemented_addrinfo_ai_addr' of github.com:matsumoto-r…

    matsumoto-r committed
    …/mruby-uv into implemented_addrinfo_ai_addr
Showing with 3 additions and 2 deletions.
  1. +3 −2 src/mrb_uv.c
View
5 src/mrb_uv.c
@@ -986,6 +986,7 @@ _uv_getaddrinfo_cb(uv_getaddrinfo_t* req, int status, struct addrinfo* res)
mrb_value args[2];
mrb_uv_addrinfo* addr = (mrb_uv_addrinfo*) req->data;
mrb_state* mrb = addr->mrb;
+ char ipaddr[17] = {'\0'};
mrb_value c = mrb_nil_value();
if (status != -1) {
@@ -994,8 +995,8 @@ _uv_getaddrinfo_cb(uv_getaddrinfo_t* req, int status, struct addrinfo* res)
OBJECT_SET(mrb, c, "family", mrb_fixnum_value(res->ai_family));
OBJECT_SET(mrb, c, "socktype", mrb_fixnum_value(res->ai_socktype));
OBJECT_SET(mrb, c, "protocol", mrb_fixnum_value(res->ai_protocol));
- // TODO: Not implemented yet!
- OBJECT_SET(mrb, c, "addr", mrb_nil_value());
+ uv_ip4_name((struct sockaddr_in*) res->ai_addr, ipaddr, 16);
+ OBJECT_SET(mrb, c, "addr", mrb_str_new_cstr(mrb, ipaddr));
OBJECT_SET(mrb, c, "canonname", mrb_str_new_cstr(mrb, res->ai_canonname ? res->ai_canonname : ""));
// TODO: Not implemented yet!
OBJECT_SET(mrb, c, "next", mrb_nil_value());
Something went wrong with that request. Please try again.