Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sys.net.Socket.select not implemented #31

Closed
sneurlax opened this issue Nov 21, 2016 · 2 comments
Closed

sys.net.Socket.select not implemented #31

sneurlax opened this issue Nov 21, 2016 · 2 comments

Comments

@sneurlax
Copy link

sneurlax commented Nov 21, 2016

Hi, I need some non-blocking sockets for my game. I'd love to use Hashlink for quick JIT testing but apparently sys.net.Socket.select is not implemented for this target.

Here's a snippet of code I'm using:

import sys.net.Socket;

class SocketServer {
  static function main() {
    var sockets : Array<sys.net.Socket> = [];
    var s = new sys.net.Socket();
    s.bind(new sys.net.Host("localhost"),5000);
    s.listen(10); // Allow a buffer of 10 pending connections. You might want this higher for a busy server
    while (true) {
      var results = sys.net.Socket.select(  
        [] // Not interested in reading
        , sockets // Writing to all clients
        , [s] // Waiting for new sockets from the server
        , 0 // Infinite timeout

      ); //

      for (c in results.write)
      {
        c.write("exit");
      }
      if (results.others.length > 0)
      {
        // Accept a new socket from the server
        var c : sys.net.Socket = s.accept();
        sockets.push(c);
        c.setBlocking(false);
        c.setFastSend(true);
        c.write("your IP is "+c.peer().host.toString()+"\n");
      }
    }
  }
}

and here's the error it produces:

Uncaught exception: SysError(Not implemented)
Called from sys.net.$Socket.select(C:\HaxeToolkit\haxe\std/hl/_std/sys/net/Socket.hx:199)

I hope I'm wrong about this and there's some fix for my problem :) otherwise I'd love to see it implemented!

@ncannasse
Copy link
Member

Ah, it seems it's actually not implemented :)
https://github.com/HaxeFoundation/haxe/blob/development/std/hl/_std/sys/net/Socket.hx#L199
I'll try to do it soon, if possible more efficiently than neko

@Simn
Copy link
Member

Simn commented Jan 29, 2017

Closed by HaxeFoundation/haxe@b47aefe

@Simn Simn closed this as completed Jan 29, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants