Server and socket

Hi, Im writing neko server and want to communicate from openfl application with it. in docs.openfl.org i found two classes:
openfl.net.Socket and sys.net.Socket and what are the differences ? any cons & pros. Don’t know with one I should use and why

Haxe includes a Socket class, but only on “sys” platforms. It won’t work on HTML5, or Flash, etc.

The OpenFL Socket class is a wrapper that should work with a sys.net.Socket on native, but also work on HTML5, and is compatible with the Flash socket class. If you find any issues using it, please let us know so we can continue to improve the implementation :slight_smile:

thx, It’s sound awesome, but I have little problem.
I’ve created neko threadServer and can connect and send data to this server easly.
but when I try to recive data on openfl client (using openfl.net.Socket ) like this:

s.addEventListener(ProgressEvent.SOCKET_DATA, function(e:ProgressEvent)
	    {
	      trace('recived');
	     // trace(s.readUTFBytes(s.bytesAvailable));
	    });

and Im sending it like this:

c.socket.output.writeString("aaa");

i’ve got instant crash with error:

Main.hx:29: conected
Called from warlordsclash.core.Hex::$statics line 1
Called from ApplicationMain::main line 123
Called from ApplicationMain::create line 55
Called from lime.app.Application::exec line 163
Called from lime._backend.native.NativeApplication::exec line 108
Called from a C function
Called from lime._backend.native.NativeApplication::handleRenderEvent line 58
Called from lime.app.Application::render line 568
Called from openfl.display.Stage::render line 956
Called from openfl.display.DisplayObjectContainer::__broadcast line 645
Called from openfl.display.DisplayObjectContainer::__broadcast line 639
Called from a C function
Called from openfl.display.DisplayObject::__broadcast line 1000
Called from a C function
Called from openfl.events.EventDispatcher::dispatchEvent line 302
Called from openfl.net.Socket::onFrame line 202
Called from haxe.io.Bytes::blit line 84
Uncaught exception - OutsideBounds

Are you using latest openfl and lime? A similar issue has been fixed recently.

1 Like

thx, now it’s working :slight_smile:

1 Like