X-Git-Url: http://nitlanguage.org diff --git a/lib/socket/socket_c.nit b/lib/socket/socket_c.nit index ba76860..8758cdf 100644 --- a/lib/socket/socket_c.nit +++ b/lib/socket/socket_c.nit @@ -145,12 +145,14 @@ extern class NativeSocket `{ int* `} `} # Sets an option for the socket - fun setsockopt(level: NativeSocketOptLevels, option_name: NativeSocketOptNames, option_value: Int) `{ + # + # Returns `true` on success. + fun setsockopt(level: NativeSocketOptLevels, option_name: NativeSocketOptNames, option_value: Int): Bool `{ int err = setsockopt(*recv, level, option_name, &option_value, sizeof(int)); if(err != 0){ - perror("Error on setsockopts: "); - exit(1); + return 0; } + return 1; `} fun bind(addrIn: NativeSocketAddrIn): Int `{ return bind(*recv, (struct sockaddr*)addrIn, sizeof(*addrIn)); `} @@ -236,7 +238,7 @@ extern class NativeSocketAddrIn `{ struct sockaddr_in* `} return sai; `} - new with(port: Int, family: NativeSocketAddressFamilies) `{ + new with_port(port: Int, family: NativeSocketAddressFamilies) `{ struct sockaddr_in *sai = NULL; sai = malloc(sizeof(struct sockaddr_in)); sai->sin_family = family;