Browse Source

added sys.net

Nicolas Cannasse 13 years ago
parent
commit
d54a9d04d7

+ 1 - 1
doc/CHANGES.txt

@@ -34,7 +34,7 @@
 	js : added --js-modern for wrapping output in a closure and ES5 strict mode
 	all : null, true and false are now keywords
 	all : neko.io.Path, cpp.io.Path and php.io.Path are now haxe.io.Path
-	neko, cpp, php : added Sys class and sys.io package and "sys" define
+	neko, cpp, php : added Sys class, sys.io and sys.net packages and "sys" define
 	all : allow to access root package with __ prefix (__.Type for example)
 
 2011-09-25: 2.08

+ 5 - 5
std/cpp/net/Host.hx → std/cpp/_std/sys/net/Host.hx

@@ -23,14 +23,14 @@
  * DAMAGE.
  *
  */
-package cpp.net;
-
+package sys.net;
 
+@:core_api
 class Host {
 
 	public var ip(default,null) : haxe.Int32;
 
-	public function new( name : String ) {
+	public function new( name : String ) : Void {
 		ip = host_resolve(name);
 	}
 
@@ -38,7 +38,7 @@ class Host {
 		return new String(host_to_string(ip));
 	}
 
-	public function reverse() {
+	public function reverse() : String {
 		return new String(host_reverse(ip));
 	}
 
@@ -46,7 +46,7 @@ class Host {
 		return new String(host_local());
 	}
 
-	static function __init__() {
+	static function __init__() : Void {
 		cpp.Lib.load("std","socket_init",0)();
 	}
 

+ 119 - 19
std/cpp/net/Socket.hx → std/cpp/_std/sys/net/Socket.hx

@@ -24,19 +24,115 @@
  *
  * Contributor: Lee McColl Sylvester
  */
-package cpp.net;
+package sys.net;
 
-typedef SocketHandle = Dynamic;
+import haxe.io.Error;
 
+private typedef SocketHandle = Dynamic;
+
+private class SocketInput extends haxe.io.Input {
+
+	var __s : SocketHandle;
+
+	public function new(s) {
+		__s = s;
+	}
+
+	public override function readByte() {
+		return try {
+			socket_recv_char(__s);
+		} catch( e : Dynamic ) {
+			if( e == "Blocking" )
+				throw Blocked;
+			else if( __s == null )
+				throw Custom(e);
+			else
+				throw new haxe.io.Eof();
+		}
+	}
+
+	public override function readBytes( buf : haxe.io.Bytes, pos : Int, len : Int ) : Int {
+		var r;
+		if (__s==null)
+			throw "Invalid handle";
+		try {
+			r = socket_recv(__s,buf.getData(),pos,len);
+		} catch( e : Dynamic ) {
+			if( e == "Blocking" )
+				throw Blocked;
+			else
+				throw Custom(e);
+		}
+		if( r == 0 )
+			throw new haxe.io.Eof();
+		return r;
+	}
+
+	public override function close() {
+		super.close();
+		if( __s != null ) socket_close(__s);
+	}
+
+	private static var socket_recv = cpp.Lib.load("std","socket_recv",4);
+	private static var socket_recv_char = cpp.Lib.load("std","socket_recv_char",1);
+	private static var socket_close = cpp.Lib.load("std","socket_close",1);
+
+}
+
+private class SocketOutput extends haxe.io.Output {
+
+	var __s : SocketHandle;
+
+	public function new(s) {
+		__s = s;
+	}
+
+	public override function writeByte( c : Int ) {
+		if (__s==null)
+			throw "Invalid handle";
+		try {
+			socket_send_char(__s, c);
+		} catch( e : Dynamic ) {
+			if( e == "Blocking" )
+				throw Blocked;
+			else
+				throw Custom(e);
+		}
+	}
+
+	public override function writeBytes( buf : haxe.io.Bytes, pos : Int, len : Int) : Int {
+		return try {
+			socket_send(__s, buf.getData(), pos, len);
+		} catch( e : Dynamic ) {
+			if( e == "Blocking" )
+				throw Blocked;
+			else
+				throw Custom(e);
+		}
+	}
+
+	public override function close() {
+		super.close();
+		if( __s != null ) socket_close(__s);
+	}
+
+	private static var socket_close = cpp.Lib.load("std","socket_close",1);
+	private static var socket_send_char = cpp.Lib.load("std","socket_send_char",2);
+	private static var socket_send = cpp.Lib.load("std","socket_send",4);
+
+}
+
+
+@:core_api
 class Socket {
 
 	private var __s : SocketHandle;
-	public var input(default,null) : SocketInput;
-	public var output(default,null) : SocketOutput;
+	public var input(default,null) : haxe.io.Input;
+	public var output(default,null) : haxe.io.Output;
 	public var custom : Dynamic;
 
-	public function new( ?s ) {
-		__s = if( s == null ) socket_new(false) else s;
+	public function new() : Void {
+		__s = socket_new(false);
 		input = new SocketInput(__s);
 		output = new SocketOutput(__s);
 	}
@@ -57,11 +153,11 @@ class Socket {
 		return bytes.toString();
 	}
 
-	public function write( content : String ) {
+	public function write( content : String ) : Void {
 		socket_write(__s, haxe.io.Bytes.ofString(content).getData() );
 	}
 
-	public function connect(host : Host, port : Int) {
+	public function connect(host : Host, port : Int) : Void {
 		try {
 			socket_connect(__s, host.ip, port);
 		} catch( s : String ) {
@@ -72,20 +168,25 @@ class Socket {
 		}
 	}
 
-	public function listen(connections : Int) {
+	public function listen(connections : Int) : Void {
 		socket_listen(__s, connections);
 	}
 
-	public function shutdown( read : Bool, write : Bool ){
+	public function shutdown( read : Bool, write : Bool ) : Void {
 		socket_shutdown(__s,read,write);
 	}
 
-	public function bind(host : Host, port : Int) {
+	public function bind(host : Host, port : Int) : Void {
 		socket_bind(__s, host.ip, port);
 	}
 
 	public function accept() : Socket {
-		return new Socket(socket_accept(__s));
+		var c = socket_accept(__s);
+		var s = Type.createEmptyInstance(Socket);
+		s.__s = c;
+		s.input = new SocketInput(c);
+		s.output = new SocketOutput(c);
+		return s;
 	}
 
 	public function peer() : { host : Host, port : Int } {
@@ -102,24 +203,23 @@ class Socket {
 		return { host : h, port : a[1] };
 	}
 
-	public function setTimeout( timeout : Float ) {
+	public function setTimeout( timeout : Float ) : Void {
 		socket_set_timeout(__s, timeout);
 	}
 
-	public function waitForRead() {
+	public function waitForRead() : Void {
 		select([this],null,null,null);
 	}
 
-	public function setBlocking( b : Bool ) {
+	public function setBlocking( b : Bool ) : Void {
 		socket_set_blocking(__s,b);
 	}
 
-	public static function newUdpSocket() {
-		return new Socket(socket_new(true));
+	public function setFastSend( b : Bool ) : Void {
+		throw "Not implemented";
 	}
 
-	// STATICS
-	public static function select(read : Array<Socket>, write : Array<Socket>, others : Array<Socket>, timeout : Null<Float>) : {read: Array<Socket>,write: Array<Socket>,others: Array<Socket>} {
+	public static function select(read : Array<Socket>, write : Array<Socket>, others : Array<Socket>, ?timeout : Float ) : {read: Array<Socket>,write: Array<Socket>,others: Array<Socket>} {
 		var neko_array = socket_select(read,write,others, timeout);
 		if (neko_array==null)
 			throw "Select error";

+ 0 - 76
std/cpp/net/SocketInput.hx

@@ -1,76 +0,0 @@
-/*
- * Copyright (c) 2005, The haXe Project Contributors
- * All rights reserved.
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE HAXE PROJECT CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE HAXE PROJECT CONTRIBUTORS BE LIABLE FOR
- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
- * DAMAGE.
- */
-package cpp.net;
-import cpp.net.Socket;
-import haxe.io.Error;
-
-class SocketInput extends haxe.io.Input {
-
-	var __s : SocketHandle;
-
-	public function new(s) {
-		__s = s;
-	}
-
-	public override function readByte() {
-		return try {
-			socket_recv_char(__s);
-		} catch( e : Dynamic ) {
-			if( e == "Blocking" )
-				throw Blocked;
-			else if( __s == null )
-				throw Custom(e);
-			else
-				throw new haxe.io.Eof();
-		}
-	}
-
-	public override function readBytes( buf : haxe.io.Bytes, pos : Int, len : Int ) : Int {
-		var r;
-		if (__s==null)
-			throw "Invalid handle";
-		try {
-			r = socket_recv(__s,buf.getData(),pos,len);
-		} catch( e : Dynamic ) {
-			if( e == "Blocking" )
-				throw Blocked;
-			else
-				throw Custom(e);
-		}
-		if( r == 0 )
-			throw new haxe.io.Eof();
-		return r;
-	}
-
-	public override function close() {
-		super.close();
-		if( __s != null ) socket_close(__s);
-	}
-
-	private static var socket_recv = cpp.Lib.load("std","socket_recv",4);
-	private static var socket_recv_char = cpp.Lib.load("std","socket_recv_char",1);
-	private static var socket_close = cpp.Lib.load("std","socket_close",1);
-
-}

+ 0 - 70
std/cpp/net/SocketOutput.hx

@@ -1,70 +0,0 @@
-/*
- * Copyright (c) 2005, The haXe Project Contributors
- * All rights reserved.
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE HAXE PROJECT CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE HAXE PROJECT CONTRIBUTORS BE LIABLE FOR
- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
- * DAMAGE.
- */
-package cpp.net;
-import cpp.net.Socket;
-import haxe.io.Error;
-
-class SocketOutput extends haxe.io.Output {
-
-	var __s : SocketHandle;
-
-	public function new(s) {
-		__s = s;
-	}
-
-	public override function writeByte( c : Int ) {
-		if (__s==null)
-			throw "Invalid handle";
-		try {
-			socket_send_char(__s, c);
-		} catch( e : Dynamic ) {
-			if( e == "Blocking" )
-				throw Blocked;
-			else
-				throw Custom(e);
-		}
-	}
-
-	public override function writeBytes( buf : haxe.io.Bytes, pos : Int, len : Int) : Int {
-		return try {
-			socket_send(__s, buf.getData(), pos, len);
-		} catch( e : Dynamic ) {
-			if( e == "Blocking" )
-				throw Blocked;
-			else
-				throw Custom(e);
-		}
-	}
-
-	public override function close() {
-		super.close();
-		if( __s != null ) socket_close(__s);
-	}
-
-	private static var socket_close = cpp.Lib.load("std","socket_close",1);
-	private static var socket_send_char = cpp.Lib.load("std","socket_send_char",2);
-	private static var socket_send = cpp.Lib.load("std","socket_send",4);
-
-}

+ 11 - 17
std/haxe/Http.hx

@@ -24,18 +24,11 @@
  */
 package haxe;
 
-#if neko
-import neko.net.Host;
-import neko.net.Socket;
-#elseif cpp
-import cpp.net.Host;
-import cpp.net.Socket;
-#elseif php
-import php.net.Host;
-import php.net.Socket;
-#end
+#if sys
+
+import sys.net.Host;
+import sys.net.Socket;
 
-#if (neko || php || cpp)
 private typedef AbstractSocket = {
 	var input(default,null) : haxe.io.Input;
 	var output(default,null) : haxe.io.Output;
@@ -45,12 +38,13 @@ private typedef AbstractSocket = {
 	function close() : Void;
 	function shutdown( read : Bool, write : Bool ) : Void;
 }
+
 #end
 
 class Http {
 
 	public var url : String;
-#if (neko || php || cpp)
+#if sys
 	public var noShutdown : Bool;
 	public var cnxTimeout : Float;
 	public var responseHeaders : Hash<String>;
@@ -64,7 +58,7 @@ class Http {
 	var headers : Hash<String>;
 	var params : Hash<String>;
 
-	#if (neko || php || cpp)
+	#if sys
 	public static var PROXY : { host : String, port : Int, auth : { user : String, pass : String } } = null;
 	#end
 
@@ -78,7 +72,7 @@ class Http {
 		params = new Hash();
 		#if js
 		async = true;
-		#elseif (neko || php || cpp)
+		#elseif sys
 		cnxTimeout = 10;
 		#end
 		#if php
@@ -247,7 +241,7 @@ class Http {
 		}
 		if( !r.sendAndLoad(small_url,r,if( param ) { if( post ) "POST" else "GET"; } else null) )
 			onError("Failed to initialize Connection");
-	#elseif (neko || php || cpp)
+	#elseif sys
 		var me = this;
 		var output = new haxe.io.BytesOutput();
 		var old = onError;
@@ -266,7 +260,7 @@ class Http {
 	#end
 	}
 
-#if (neko || php || cpp)
+#if sys
 
 	public function fileTransfert( argname : String, filename : String, file : haxe.io.Input, size : Int ) {
 		this.file = { param : argname, filename : filename, io : file, size : size };
@@ -282,7 +276,7 @@ class Http {
 		if( sock == null ) {
 			if( secure ) {
 				#if php
-				sock = Socket.newSslSocket();
+				sock = new php.net.SslSocket();
 				#elseif hxssl
 				sock = new neko.tls.Socket();
 				#else

+ 2 - 6
std/haxe/remoting/SocketProtocol.hx

@@ -31,12 +31,8 @@ typedef Socket =
 		flash.XMLSocket
 	#elseif js
 		js.XMLSocket
-	#elseif neko
-		neko.net.Socket
-	#elseif php
-		php.net.Socket
-	#elseif cpp
-		cpp.net.Socket
+	#elseif sys
+		sys.net.Socket
 	#else
 		Dynamic
 	#end

+ 6 - 6
std/neko/net/Host.hx → std/neko/_std/sys/net/Host.hx

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, The haXe Project Contributors
+ * Copyright (c) 2005-2012, The haXe Project Contributors
  * All rights reserved.
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are met:
@@ -23,14 +23,14 @@
  * DAMAGE.
  *
  */
-package neko.net;
-
+package sys.net;
 
+@:core_api
 class Host {
 
 	public var ip(default,null) : haxe.Int32;
 
-	public function new( name : String ) {
+	public function new( name : String ) : Void {
 		ip = host_resolve(untyped name.__s);
 	}
 
@@ -38,7 +38,7 @@ class Host {
 		return new String(host_to_string(ip));
 	}
 
-	public function reverse() {
+	public function reverse() : String {
 		return new String(host_reverse(ip));
 	}
 
@@ -46,7 +46,7 @@ class Host {
 		return new String(host_local());
 	}
 
-	static function __init__() {
+	static function __init__() : Void {
 		neko.Lib.load("std","socket_init",0)();
 	}
 

+ 113 - 24
std/neko/net/Socket.hx → std/neko/_std/sys/net/Socket.hx

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, The haXe Project Contributors
+ * Copyright (c) 2005-2012, The haXe Project Contributors
  * All rights reserved.
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are met:
@@ -22,22 +22,111 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
  * DAMAGE.
  *
- * Contributor: Lee McColl Sylvester
  */
-package neko.net;
+package sys.net;
+import haxe.io.Error;
 
-enum SocketHandle {
+private enum SocketHandle {
 }
 
+private class SocketOutput extends haxe.io.Output {
+
+	var __s : SocketHandle;
+
+	public function new(s) {
+		__s = s;
+	}
+
+	public override function writeByte( c : Int ) {
+		try {
+			socket_send_char(__s, c);
+		} catch( e : Dynamic ) {
+			if( e == "Blocking" )
+				throw Blocked;
+			else
+				throw Custom(e);
+		}
+	}
+
+	public override function writeBytes( buf : haxe.io.Bytes, pos : Int, len : Int) : Int {
+		return try {
+			socket_send(__s, buf.getData(), pos, len);
+		} catch( e : Dynamic ) {
+			if( e == "Blocking" )
+				throw Blocked;
+			else
+				throw Custom(e);
+		}
+	}
+
+	public override function close() {
+		super.close();
+		if( __s != null ) socket_close(__s);
+	}
+
+	private static var socket_close = neko.Lib.load("std","socket_close",1);
+	private static var socket_send_char = neko.Lib.load("std","socket_send_char",2);
+	private static var socket_send = neko.Lib.load("std","socket_send",4);
+
+}
+
+private class SocketInput extends haxe.io.Input {
+
+	var __s : SocketHandle;
+
+	public function new(s) {
+		__s = s;
+	}
+
+	public override function readByte() : Int {
+		return try {
+			socket_recv_char(__s);
+		} catch( e : Dynamic ) {
+			if( e == "Blocking" )
+				throw Blocked;
+			else if( __s == null )
+				throw Custom(e);
+			else
+				throw new haxe.io.Eof();
+		}
+	}
+
+	public override function readBytes( buf : haxe.io.Bytes, pos : Int, len : Int ) : Int {
+		var r;
+		try {
+			r = socket_recv(__s,buf.getData(),pos,len);
+		} catch( e : Dynamic ) {
+			if( e == "Blocking" )
+				throw Blocked;
+			else
+				throw Custom(e);
+		}
+		if( r == 0 )
+			throw new haxe.io.Eof();
+		return r;
+	}
+
+	public override function close() {
+		super.close();
+		if( __s != null ) socket_close(__s);
+	}
+
+	private static var socket_recv = neko.Lib.load("std","socket_recv",4);
+	private static var socket_recv_char = neko.Lib.load("std","socket_recv_char",1);
+	private static var socket_close = neko.Lib.load("std","socket_close",1);
+
+}
+
+@:core_api
 class Socket {
 
 	private var __s : SocketHandle;
-	public var input(default,null) : SocketInput;
-	public var output(default,null) : SocketOutput;
+	public var input(default,null) : haxe.io.Input;
+	public var output(default,null) : haxe.io.Output;
 	public var custom : Dynamic;
 
-	public function new( ?s ) {
-		__s = if( s == null ) socket_new(false) else s;
+	public function new() : Void {
+		__s = socket_new(false);
 		input = new SocketInput(__s);
 		output = new SocketOutput(__s);
 	}
@@ -56,11 +145,11 @@ class Socket {
 		return socket_read(__s);
 	}
 
-	public function write( content : String ) {
+	public function write( content : String ) : Void {
 		socket_write(__s, untyped content.__s);
 	}
 
-	public function connect(host : Host, port : Int) {
+	public function connect(host : Host, port : Int) : Void {
 		try {
 			socket_connect(__s, host.ip, port);
 		} catch( s : String ) {
@@ -71,20 +160,25 @@ class Socket {
 		}
 	}
 
-	public function listen(connections : Int) {
+	public function listen(connections : Int) : Void {
 		socket_listen(__s, connections);
 	}
 
-	public function shutdown( read : Bool, write : Bool ){
+	public function shutdown( read : Bool, write : Bool ) : Void {
 		socket_shutdown(__s,read,write);
 	}
 
-	public function bind(host : Host, port : Int) {
+	public function bind(host : Host, port : Int) : Void {
 		socket_bind(__s, host.ip, port);
 	}
 
 	public function accept() : Socket {
-		return new Socket(socket_accept(__s));
+		var c = socket_accept(__s);
+		var s = Type.createEmptyInstance(Socket);
+		s.__s = c;
+		s.input = new SocketInput(c);
+		s.output = new SocketOutput(c);
+		return s;
 	}
 
 	public function peer() : { host : Host, port : Int } {
@@ -101,28 +195,23 @@ class Socket {
 		return { host : h, port : a[1] };
 	}
 
-	public function setTimeout( timeout : Float ) {
+	public function setTimeout( timeout : Float ) : Void {
 		socket_set_timeout(__s, timeout);
 	}
 
-	public function waitForRead() {
+	public function waitForRead() : Void {
 		select([this],null,null,null);
 	}
 
-	public function setBlocking( b : Bool ) {
+	public function setBlocking( b : Bool ) : Void {
 		socket_set_blocking(__s,b);
 	}
 
-	public function setFastSend( b : Bool ) {
+	public function setFastSend( b : Bool ) : Void {
 		socket_set_fast_send(__s,b);
 	}
 
-	public static function newUdpSocket() {
-		return new Socket(socket_new(true));
-	}
-
-	// STATICS
-	public static function select(read : Array<Socket>, write : Array<Socket>, others : Array<Socket>, timeout : Float) : {read: Array<Socket>,write: Array<Socket>,others: Array<Socket>} {
+	public static function select(read : Array<Socket>, write : Array<Socket>, others : Array<Socket>, ?timeout : Float) : {read: Array<Socket>,write: Array<Socket>,others: Array<Socket>} {
 		var c = untyped __dollar__hnew( 1 );
 		var f = function( a : Array<Socket> ){
 			if( a == null ) return null;

+ 1 - 0
std/neko/net/Poll.hx

@@ -23,6 +23,7 @@
  * DAMAGE.
  */
 package neko.net;
+import sys.net.Socket;
 
 class Poll {
 

+ 2 - 1
std/neko/net/ServerLoop.hx

@@ -23,6 +23,7 @@
  * DAMAGE.
  */
 package neko.net;
+import sys.net.Socket;
 
 private typedef ServerClient<ClientData> = {
 	var sock : Socket;
@@ -182,7 +183,7 @@ class ServerLoop<ClientData> {
 	/**
 		Run the server. This function should never return.
 	**/
-	public function run( host : Host, port : Int ) {
+	public function run( host : sys.net.Host, port : Int ) {
 		var serv = new Socket();
 		serv.bind(host,port);
 		serv.listen(listenCount);

+ 0 - 74
std/neko/net/SocketInput.hx

@@ -1,74 +0,0 @@
-/*
- * Copyright (c) 2005, The haXe Project Contributors
- * All rights reserved.
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE HAXE PROJECT CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE HAXE PROJECT CONTRIBUTORS BE LIABLE FOR
- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
- * DAMAGE.
- */
-package neko.net;
-import neko.net.Socket;
-import haxe.io.Error;
-
-class SocketInput extends haxe.io.Input {
-
-	var __s : SocketHandle;
-
-	public function new(s) {
-		__s = s;
-	}
-
-	public override function readByte() : Int {
-		return try {
-			socket_recv_char(__s);
-		} catch( e : Dynamic ) {
-			if( e == "Blocking" )
-				throw Blocked;
-			else if( __s == null )
-				throw Custom(e);
-			else
-				throw new haxe.io.Eof();
-		}
-	}
-
-	public override function readBytes( buf : haxe.io.Bytes, pos : Int, len : Int ) : Int {
-		var r;
-		try {
-			r = socket_recv(__s,buf.getData(),pos,len);
-		} catch( e : Dynamic ) {
-			if( e == "Blocking" )
-				throw Blocked;
-			else
-				throw Custom(e);
-		}
-		if( r == 0 )
-			throw new haxe.io.Eof();
-		return r;
-	}
-
-	public override function close() {
-		super.close();
-		if( __s != null ) socket_close(__s);
-	}
-
-	private static var socket_recv = neko.Lib.load("std","socket_recv",4);
-	private static var socket_recv_char = neko.Lib.load("std","socket_recv_char",1);
-	private static var socket_close = neko.Lib.load("std","socket_close",1);
-
-}

+ 0 - 68
std/neko/net/SocketOutput.hx

@@ -1,68 +0,0 @@
-/*
- * Copyright (c) 2005, The haXe Project Contributors
- * All rights reserved.
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE HAXE PROJECT CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE HAXE PROJECT CONTRIBUTORS BE LIABLE FOR
- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
- * DAMAGE.
- */
-package neko.net;
-import neko.net.Socket;
-import haxe.io.Error;
-
-class SocketOutput extends haxe.io.Output {
-
-	var __s : SocketHandle;
-
-	public function new(s) {
-		__s = s;
-	}
-
-	public override function writeByte( c : Int ) {
-		try {
-			socket_send_char(__s, c);
-		} catch( e : Dynamic ) {
-			if( e == "Blocking" )
-				throw Blocked;
-			else
-				throw Custom(e);
-		}
-	}
-
-	public override function writeBytes( buf : haxe.io.Bytes, pos : Int, len : Int) : Int {
-		return try {
-			socket_send(__s, buf.getData(), pos, len);
-		} catch( e : Dynamic ) {
-			if( e == "Blocking" )
-				throw Blocked;
-			else
-				throw Custom(e);
-		}
-	}
-
-	public override function close() {
-		super.close();
-		if( __s != null ) socket_close(__s);
-	}
-
-	private static var socket_close = neko.Lib.load("std","socket_close",1);
-	private static var socket_send_char = neko.Lib.load("std","socket_send_char",2);
-	private static var socket_send = neko.Lib.load("std","socket_send",4);
-
-}

+ 1 - 1
std/neko/net/ThreadRemotingServer.hx

@@ -56,7 +56,7 @@ class ThreadRemotingServer extends ThreadServer<haxe.remoting.SocketConnection,S
 		super.run(host,port);
 	}
 
-	public override function clientConnected( s : neko.net.Socket ) {
+	public override function clientConnected( s : sys.net.Socket ) {
 		var ctx = new haxe.remoting.Context();
 		var cnx = haxe.remoting.SocketConnection.create(s,ctx);
 		var me = this;

+ 12 - 12
std/neko/net/ThreadServer.hx

@@ -28,12 +28,12 @@ private typedef ThreadInfos = {
 	var id : Int;
 	var t : neko.vm.Thread;
 	var p : neko.net.Poll;
-	var socks : Array<neko.net.Socket>;
+	var socks : Array<sys.net.Socket>;
 }
 
 private typedef ClientInfos<Client> = {
 	var client : Client;
-	var sock : neko.net.Socket;
+	var sock : sys.net.Socket;
 	var thread : ThreadInfos;
 	var buf : haxe.io.Bytes;
 	var bufpos : Int;
@@ -42,7 +42,7 @@ private typedef ClientInfos<Client> = {
 class ThreadServer<Client,Message> {
 
 	var threads : Array<ThreadInfos>;
-	var sock : neko.net.Socket;
+	var sock : sys.net.Socket;
 	var worker : neko.vm.Thread;
 	var timer : neko.vm.Thread;
 	public var listen : Int;
@@ -122,7 +122,7 @@ class ThreadServer<Client,Message> {
 				}
 			}
 		while( true ) {
-			var m : { s : neko.net.Socket, cnx : Bool } = neko.vm.Thread.readMessage(t.socks.length == 0);
+			var m : { s : sys.net.Socket, cnx : Bool } = neko.vm.Thread.readMessage(t.socks.length == 0);
 			if( m == null )
 				break;
 			if( m.cnx )
@@ -167,7 +167,7 @@ class ThreadServer<Client,Message> {
 			work(callback(onError,e,stack));
 	}
 
-	function addClient( sock : neko.net.Socket ) {
+	function addClient( sock : sys.net.Socket ) {
 		var start = Std.random(nthreads);
 		for( i in 0...nthreads ) {
 			var t = threads[(start + i)%nthreads];
@@ -187,7 +187,7 @@ class ThreadServer<Client,Message> {
 		refuseClient(sock);
 	}
 
-	function refuseClient( sock : neko.net.Socket) {
+	function refuseClient( sock : sys.net.Socket) {
 		// we have reached maximum number of active clients
 		sock.close();
 	}
@@ -215,14 +215,14 @@ class ThreadServer<Client,Message> {
 		}
 	}
 
-	public function addSocket( s : neko.net.Socket ) {
+	public function addSocket( s : sys.net.Socket ) {
 		s.setBlocking(false);
 		work(callback(addClient,s));
 	}
 
 	public function run( host, port ) {
-		sock = new neko.net.Socket();
-		sock.bind(new neko.net.Host(host),port);
+		sock = new sys.net.Socket();
+		sock.bind(new sys.net.Host(host),port);
 		sock.listen(listen);
 		init();
 		while( true ) {
@@ -234,7 +234,7 @@ class ThreadServer<Client,Message> {
 		}
 	}
 
-	public function sendData( s : neko.net.Socket, data : String ) {
+	public function sendData( s : sys.net.Socket, data : String ) {
 		try {
 			s.write(data);
 		} catch( e : Dynamic ) {
@@ -242,7 +242,7 @@ class ThreadServer<Client,Message> {
 		}
 	}
 
-	public function stopClient( s : neko.net.Socket ) {
+	public function stopClient( s : sys.net.Socket ) {
 		var infos : ClientInfos<Client> = s.custom;
 		try s.shutdown(true,true) catch( e : Dynamic ) { };
 		infos.thread.t.sendMessage({ s : s, cnx : false });
@@ -256,7 +256,7 @@ class ThreadServer<Client,Message> {
 		errorOutput.flush();
 	}
 
-	public dynamic function clientConnected( s : neko.net.Socket ) : Client {
+	public dynamic function clientConnected( s : sys.net.Socket ) : Client {
 		return null;
 	}
 

+ 2 - 2
std/php/net/Host.hx → std/php/_std/sys/net/Host.hx

@@ -23,7 +23,7 @@
  * DAMAGE.
  *
  */
-package php.net;
+package sys.net;
 
 
 class Host {
@@ -31,7 +31,7 @@ class Host {
 	private var _ip : String;
 	public var ip(default,null) : haxe.Int32;
 
-	public function new( name : String ) {
+	public function new( name : String ) : Void {
 		if(~/^(\d{1,3}\.){3}\d{1,3}$/.match(name)) {
 		  _ip = name;
 		} else {

+ 37 - 40
std/php/net/Socket.hx → std/php/_std/sys/net/Socket.hx

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, The haXe Project Contributors
+ * Copyright (c) 2005-2012, The haXe Project Contributors
  * All rights reserved.
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are met:
@@ -22,30 +22,27 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
  * DAMAGE.
  *
- * Contributor: Lee McColl Sylvester
  */
-package php.net;
+package sys.net;
 
 import sys.io.File;
 
-typedef SocketHandle = FileHandle;
-
+@:core_api
 class Socket {
-	private var __s : SocketHandle;
-	public var input(default,null) : SocketInput;
-	public var output(default,null) : SocketOutput;
-	public var custom : Dynamic;
 
-	public var protocol(default, null) : String;
+	private var __s : FileHandle;
+	private var protocol : String;
+	public var input(default,null) : haxe.io.Input;
+	public var output(default,null) : haxe.io.Output;
+	public var custom : Dynamic;
 
-	public function new( ?s ) {
-		__s = s;
-		input = untyped new SocketInput(__s);
-		output = untyped new SocketOutput(__s);
+	public function new() : Void {
+		input = untyped new sys.io.FileInput(null);
+		output = untyped new sys.io.FileOutput(null);
 		protocol = "tcp";
 	}
 
-	private function assignHandler() {
+	private function assignHandler() : Void {
 		untyped input.__f = __s;
 		untyped output.__f = __s;
 	}
@@ -66,11 +63,11 @@ class Socket {
 		return b;
 	}
 
-	public function write( content : String ) {
+	public function write( content : String ) : Void {
 		return untyped __call__('fwrite', __s, content);
 	}
 
-	public function connect(host : Host, port : Int) {
+	public function connect(host : Host, port : Int) : Void {
 		var errs = null;
 		var errn = null;
 		var r = untyped __call__('stream_socket_client', protocol + '://' +host._ip + ':' + port, errn, errs);
@@ -79,14 +76,15 @@ class Socket {
 		assignHandler();
 	}
 
-	public function listen(connections : Int) {
+	public function listen(connections : Int) : Void {
+		throw "Not implemented";
 /* TODO: ??????
 		var r = untyped __call__('socket_listen', __s, connections);
 		checkError(r);
 */
 	}
 
-	public function shutdown( read : Bool, write : Bool ){
+	public function shutdown( read : Bool, write : Bool ) : Void {
 		var r;
 		if(untyped __call__("function_exists", "stream_socket_shutdown")) {
 			var rw = read && write ? 2 : (write ? 1 : (read ? 0 : 2));
@@ -97,7 +95,7 @@ class Socket {
 		checkError(r, 0, 'Unable to Shutdown');
 	}
 
-	public function bind(host : Host, port : Int) {
+	public function bind(host : Host, port : Int) : Void {
 		var errs = null;
 		var errn = null;
 		var r = untyped __call__('stream_socket_server', protocol + '://' +host._ip + ':' + port, errn, errs, (protocol=="udp") ? __php__('STREAM_SERVER_BIND') : __php__('STREAM_SERVER_BIND | STREAM_SERVER_LISTEN'));
@@ -109,10 +107,13 @@ class Socket {
 	public function accept() : Socket {
 		var r = untyped __call__('stream_socket_accept', __s);
 		checkError(r, 0, 'Unable to accept connections on socket');
-		return untyped new Socket(cast r);
+		var s = new Socket();
+		s.__s = cast r;
+		s.assignHandler();
+		return s;
 	}
 
-	private function hpOfString(s : String) {
+	private function hpOfString(s : String) : { host : Host, port : Int } {
 		var parts = s.split(':');
 		if(parts.length == 2) {
 			return { host : new Host(parts[0]), port : Std.parseInt(parts[1]) };
@@ -133,32 +134,27 @@ class Socket {
 		return hpOfString(r);
 	}
 
-	public function setTimeout( timeout : Float ) {
+	public function setTimeout( timeout : Float ) : Void {
 		var s = Std.int(timeout);
 		var ms = Std.int((timeout-s)*1000000);
 		var r = untyped __call__('stream_set_timeout', __s, s, ms);
 		checkError(r, 0, 'Unable to set timeout');
 	}
 
-	public function setBlocking( b : Bool ) {
+	public function setBlocking( b : Bool ) : Void {
 		var r = untyped __call__('stream_set_blocking', __s, b);
 		checkError(r, 0, 'Unable to block');
 	}
 
-	// STATICS
-	public static function newUdpSocket() {
-		var s = new Socket();
-		s.protocol = "udp";
-		return s;
+	public function setFastSend( b : Bool ) : Void {
+		throw "Not implemented";
 	}
 
-	public static function newSslSocket() {
-		var s = new Socket();
-		s.protocol = "ssl";
- 		return s;
- 	}
+	public function waitForRead() : Void {
+		select([this],null,null);
+	}
 
-	private static function checkError(r : Bool, code : Int, msg : String) {
+	private static function checkError(r : Bool, code : Int, msg : String) : Void {
 		if(!untyped __physeq__(r, false)) return;
 		throw haxe.io.Error.Custom('Error ['+code+']: ' +msg);
 	}
@@ -170,10 +166,11 @@ class Socket {
 	private static function getProtocol(protocol : String) : Int {
 		return untyped __call__('getprotobyname', protocol);
  	}
-}
 
-enum SocketDomain {
-	AfInet;
-	AfInet6;
-	AfUnix;
+	public static function select(read : Array<Socket>, write : Array<Socket>, others : Array<Socket>, ?timeout : Float) : { read: Array<Socket>,write: Array<Socket>,others: Array<Socket> }
+	{
+		throw "Not implemented";
+		return null;
+	}
+
 }

+ 10 - 2
std/php/net/SocketOutput.hx → std/php/net/SslSocket.hx

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, The haXe Project Contributors
+ * Copyright (c) 2005-2012, The haXe Project Contributors
  * All rights reserved.
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are met:
@@ -21,7 +21,15 @@
  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
  * DAMAGE.
+ *
  */
 package php.net;
 
-typedef SocketOutput = sys.io.FileOutput;
+class SslSocket extends sys.net.Socket {
+
+	public function new() : Void {
+		super();
+		protocol = "ssl";
+	}
+
+}

+ 35 - 3
std/php/net/SocketInput.hx → std/sys/net/Host.hx

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, The haXe Project Contributors
+ * Copyright (c) 2005-2012, The haXe Project Contributors
  * All rights reserved.
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are met:
@@ -21,7 +21,39 @@
  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
  * DAMAGE.
+ *
  */
-package php.net;
+package sys.net;
+
+/**
+	A given IP host name.
+**/
+extern class Host {
+
+	/**
+		The actual IP corresponding to the host.
+	**/
+	var ip(default,null) : haxe.Int32;
+
+	/**
+		Creates a new Host : the name can be an IP in the form "127.0.0.1" or an host name such as "google.com", in which case
+		the corresponding IP address is resolved using DNS. An exception occur if the host name could not be found.
+	**/
+	function new( name : String ) : Void;
+
+	/**
+		Returns the IP representation of the host
+	**/
+	function toString() : String;
+
+	/**
+		Perform a reverse-DNS query to resolve a host name from an IP.
+	**/
+	function reverse() : String;
+
+	/**
+		Returns the local computer host name
+	**/
+	static function localhost() : String;
 
-typedef SocketInput = sys.io.FileInput;
+}

+ 134 - 0
std/sys/net/Socket.hx

@@ -0,0 +1,134 @@
+/*
+ * Copyright (c) 2005-2012, The haXe Project Contributors
+ * All rights reserved.
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ *   - Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ *   - Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE HAXE PROJECT CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE HAXE PROJECT CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ *
+ */
+package sys.net;
+
+/**
+	A TCP socket class : allow you to both connect to a given server and exchange messages or start your own server and wait for connections.
+**/
+extern class Socket {
+
+	/**
+		The stream on which you can read available data. By default the stream is blocking until the requested data is available,
+		use [setBlocking(false)] or [setTimeout] to prevent infinite waiting.
+	**/
+	var input(default,null) : haxe.io.Input;
+
+	/**
+		The stream on which you can send data. Please note that in case the output buffer you will block while writing the data, use [setBlocking(false)] or [setTimeout] to prevent that.
+	**/
+	var output(default,null) : haxe.io.Output;
+
+	/**
+		A custom value that can be associated with the socket. Can be used to retreive your custom infos after a [select].
+	***/
+	var custom : Dynamic;
+
+	/**
+		Creates a new unconnected socket.
+	**/
+	function new() : Void;
+
+	/**
+		Closes the socket : make sure to properly close all your sockets or you will crash when you run out of file descriptors.
+	**/
+	function close() : Void;
+
+	/**
+		Read the whole data available on the socket.
+	**/
+	function read() : String;
+
+	/**
+		Write the whole data to the socket output.
+	**/
+	function write( content : String ) : Void;
+
+	/**
+		Connect to the given server host/port. Throw an exception in case we couldn't sucessfully connect.
+	**/
+	function connect( host : Host, port : Int ) : Void;
+
+	/**
+		Allow the socket to listen for incoming questions. The parameter tells how many pending connections we can have until they get refused. Use [accept()] to accept incoming connections.
+	**/
+	function listen( connections : Int ) : Void;
+
+	/**
+		Shutdown the socket, either for reading or writing.
+	**/
+	function shutdown( read : Bool, write : Bool ) : Void;
+
+	/**
+		Bind the socket to the given host/port so it can afterwards listen for connections there.
+	**/
+	function bind( host : Host, port : Int ) : Void;
+
+	/**
+		Accept a new connected client. This will return a connected socket on which you can read/write some data.
+	**/
+	function accept() : Socket;
+
+	/**
+		Return the informations about the other side of a connected socket.
+	**/
+	function peer() : { host : Host, port : Int };
+
+	/**
+		Return the informations about our side of a connected socket.
+	**/
+	function host() : { host : Host, port : Int };
+
+	/**
+		Gives a timeout after which blocking socket operations (such as reading and writing) will abort and throw an exception.
+	**/
+	function setTimeout( timeout : Float ) : Void;
+
+	/**
+		Block until some data is available for read on the socket.
+	**/
+	function waitForRead() : Void;
+
+	/**
+		Change the blocking mode of the socket. A blocking socket is the default behavior. A non-blocking socket will abort blocking operations immediatly by throwing a haxe.io.Error.Blocking value.
+	**/
+	function setBlocking( b : Bool ) : Void;
+
+	/**
+		Allows the socket to immediatly send the data when written to its output : this will cause less ping but might increase the number of packets / data size, especially when doing a lot of small writes.
+	**/
+	function setFastSend( b : Bool ) : Void;
+
+	/**
+		Wait until one of the sockets groups is ready for the given operation :
+		[read] contains sockets on which we want to wait for available data to be read,
+		[write] contains sockets on which we want to wait until we are allowed to write some data to their output buffers,
+		[others] contains sockets on which we want to wait for exceptional conditions.
+		[select] will block until one of the condition is met, in which case it will return the sockets for which the condition was true.
+		In case a [timeout] (in seconds) is specified, select might wait at worse until the timeout expires.
+	**/
+	static function select(read : Array<Socket>, write : Array<Socket>, others : Array<Socket>, ?timeout : Float) : { read: Array<Socket>,write: Array<Socket>,others: Array<Socket> };
+
+}