Skip to content

UDP support on hxcpp #3951

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

Closed
PDeveloper opened this issue Mar 2, 2015 · 10 comments
Closed

UDP support on hxcpp #3951

PDeveloper opened this issue Mar 2, 2015 · 10 comments
Assignees
Labels
platform-cpp Everything related to CPP / C++
Milestone

Comments

@PDeveloper
Copy link

So it seems to be implemented:
https://github.com/HaxeFoundation/hxcpp/blob/8bc5141ee3edbad2046fa31fb3be853845a9607c/project/libs/std/Socket.cpp#L138

Yet on the haxe side, there isn't any cpp sys.net.UdpSocket class, only the default one which throws "not implemented"
https://github.com/HaxeFoundation/haxe/blob/development/std/sys/net/UdpSocket.hx

Surprised that haxe has no Udp support for this long! : O

P.

@ncannasse
Copy link
Member

Ping @hughsando

@hughsando
Copy link
Member

I could basically copy the neko file over, but I'm not 100% sure how to test this.
I would appreciate a pull-request on this one - should be easy enough if no changes are required on the hxcpp side. Otherwise a working neko example would help.

@Simn Simn modified the milestone: 3.3 Mar 24, 2015
@eminfedar
Copy link

Still not implemented? I got 'primitive not found' error both on neko and cpp.

@hughsando
Copy link
Member

Cpp should be giving a "Not available on this platform" error?
I need some kind of test program before I can move forwards on this one.

@ncannasse
Copy link
Member

@hughsando as soon as you add sendto/recvfrom it should be pretty straightforward:
HaxeFoundation/neko@8b40c09

@hughsando
Copy link
Member

No test pair lying around on your hard drive?

On Tue, Sep 29, 2015 at 4:05 PM, Nicolas Cannasse [email protected]
wrote:

@hughsando https://github.com/hughsando as soon as you add
sendto/recvfrom it should be pretty straightforward:
HaxeFoundation/neko@8b40c09
HaxeFoundation/neko@8b40c09


Reply to this email directly or view it on GitHub
#3951 (comment)
.

@ncannasse
Copy link
Member

Sorry no, but usually you would create two UDP sockets, then have one sendTo A and B recvFrom will return both the data and A address.

here's some server code snip:

        var addr = new sys.net.Address();
        var buf = haxe.io.Bytes.alloc(2048);
        var lastCheck = haxe.Timer.stamp();
        while( true ) {
            var len = try sock.readFrom(buf, 0, buf.length, addr) catch( e : haxe.io.Eof ) 0;

And the client (in Flash)

        udpSock = new flash.net.DatagramSocket();
        udpSock.connect(udp.host, udp.port);
        udpSock.addEventListener(flash.events.DatagramSocketDataEvent.DATA, function(e:flash.events.DatagramSocketDataEvent) {
            var i = new haxe.io.BytesInput(haxe.io.Bytes.ofData(e.data));
        });
        udpSock.receive();
        var b = new haxe.io.BytesOutput();
        b.writeByte(0);
        b.writeInt32(uid);
        b.writeByte(2);
        udpSock.send(b.getBytes().getData());

@whilesoftware
Copy link

This seems like a reasonable template for a test:
https://github.com/whilesoftware/hxudp/blob/master/test/UdpTest.hx

@hughsando
Copy link
Member

I'm not really after a "unit test" just anything that uses the neko api and
actually works.

However, I have added the code completely untested so I guess we can do
this in reverse and write the test at the end.

On Wed, Oct 14, 2015 at 4:42 AM, Alan [email protected] wrote:

This seems like a reasonable template for a test:
https://github.com/whilesoftware/hxudp/blob/master/test/UdpTest.hx


Reply to this email directly or view it on GitHub
#3951 (comment)
.

@Simn Simn modified the milestones: 3.3.0-rc1, 3.4 Feb 23, 2016
@Simn Simn added the platform-cpp Everything related to CPP / C++ label Apr 4, 2016
@hughsando
Copy link
Member

The udp code is in there now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
platform-cpp Everything related to CPP / C++
Projects
None yet
Development

No branches or pull requests

6 participants