[haXe] Socket

Nicolas Cannasse ncannasse at motion-twin.com
Sat Apr 22 14:56:46 CEST 2006


> Hi Nicolas,
>  
> I tried your patch but neko index.n still gives:
> Called from <null> line 1
> Called from Index.hx line 8
> Called from D:\\dev\\haxe\\haxe-beta5/std/neko/Socket.hx line 63
> Called from a C function
> Called from D:\\dev\\haxe\\haxe-beta5/std/neko/Socket.hx line 73
> Uncaught exception - std at socket_new <mailto:std at socket_new>

Yes sorry, on Windows there was something missing to initialize the
socket API. Add the following to haxe/std/neko/Socket.hx :

	static function __init__() {
		Lib.load("std","socket_init",0)();
	}

> When run from the webserver I get:
> Called from tools/WebServer.nml line 433
> Called from tools/WebServer.nml line 406
> Called from <null> line 1
> Called from Index.hx line 9
> Called from D:\\dev\\haxe\\haxe-beta5/std/neko/Socket.hx line 147
> Exception : Neko_error(std at socket_listen <mailto:std at socket_listen>)
>  
>  
> The code I'm trying to run is:
>   var sock = new neko.Socket();
>   sock.listen(1);
>   var s : neko.Socket = sock.accept();
>   while (true) {
>    var data : String = "This is a test";
>    sock.write(data);
>   }

This is normal, you need first to "bind" the socket before doing "listen".

Nicolas



More information about the Haxe mailing list