Skip to content

Instantly share code, notes, and snippets.

@djgoku
Created July 6, 2016 05:17
Show Gist options
  • Save djgoku/06a14d31c3646f2309f1d16c9b018b86 to your computer and use it in GitHub Desktop.
Save djgoku/06a14d31c3646f2309f1d16c9b018b86 to your computer and use it in GitHub Desktop.
use v6;
use NativeCall;
# int inet_pton(int af, const char * restrict src, void * restrict dst);
sub inet_pton(int32, Str, uint32 is rw) returns int32 is native(Str) { * }
# const char *inet_ntop(int af, const void * restrict src, char * restrict dst, socklen_t size);
sub inet_ntop(int32, uint32, Str is rw, uint8) returns Str is native(Str) { * }
my uint32 $s_addr;
my Str $ip;
inet_pton(2, "192.168.2.33", $s_addr);
say $s_addr;
say inet_ntop(2, $s_addr, $ip, 16);
say $ip;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment