making udp server command line program with haxe

114 views
Skip to first unread message

Chase de Languillette

unread,
Jul 2, 2015, 3:33:01 AM7/2/15
to haxe...@googlegroups.com
What i'd like to do is make a udp program in haxe that can run on the command line. I'm trying to use hxudp to handle my udp communication (https://github.com/andyli/hxudp). I've gotten hxudp compiling with lime & flixel no problem in a client app, but i'd like to reuse this library (and my own netcode built on top of hxudp) to make a matchmaking/NAT-punchthrough server that purely runs on the command line.

So far i'm having some problems getting this working, and I'm hoping it's just my lack of expertise with the haxe compiler :)

Not really sure where to start asking questions, so here's a list - 

1. is this even possible (lol)? most of what i've seen with haxe involves using lime to compile to make visual games.

2. i think it is indeed possible based on the hello world example in the haxe documentation (http://haxe.org/manual/introduction-hello-world.html). i see in that example it invokes the haxe compiler with the --interp flag. is that flag actually necessary for my server program to run on the command line? it looks like not using that flag omits my trace statements and sometimes produces different errors (see #3)...not really sure what's going on underneath the hood there.

3. right now i'm trying to invoke the haxe compiler kinda like this - 
haxe -main Main --interp -cp source/

whereas the hxudp stuff is in my source folder. i know it's linking up right because i'm getting errors in hxudp's UdpSocket.hx file (https://github.com/andyli/hxudp/blob/master/src/hxudp/UdpSocket.hx) - 
UdpSocket.hx:62: characters 29-67 : You cannot use the library 'hxudp' inside a macro
what does that macro error even mean?

I tried removing the --interp flag and i get a bunch of errors about not finding Lib
UdpSocket.hx:62: characters 29-37 : Unknown identifier : Lib
UdpSocket.hx:74: characters 32-40 : Unknown identifier : Lib
UdpSocket.hx:80: characters 33-41 : Unknown identifier : Lib
..etc

4. is this all just some fundamental misunderstanding and i can actually use lime for this? it seemed like no matter what i did, compiling with lime always wanted to open up a window for visuals


It'd be pretty sweet to get this working! Thanks for taking a look :)

Dion Whitehead Amago

unread,
Jul 2, 2015, 3:28:16 PM7/2/15
to haxe...@googlegroups.com
I would probably go with the JS to Node.js platform. Node.js is built for this sort of use case.

Maximiliano Fernández

unread,
Jul 2, 2015, 4:40:12 PM7/2/15
to haxe...@googlegroups.com
There he uses sys.net.Socket class, that is a TCP Socket class. You can change that by sys.net.UdpSocket class, and make something worth of it. Hope this helps ;)

More info: http://api.haxe.org/sys/net/UdpSocket.html

Maximiliano Fernández do Santos

0 1 0              0 1 0
0 0 1  Rammserker  1 0 0
1 1 1              1 1 1

--
To post to this group haxe...@googlegroups.com
http://groups.google.com/group/haxelang?hl=en
---
You received this message because you are subscribed to the Google Groups "Haxe" group.
For more options, visit https://groups.google.com/d/optout.

Chase de Languillette

unread,
Jul 2, 2015, 5:45:04 PM7/2/15
to haxe...@googlegroups.com
@Dion - 
I am aware of node (and have made a matchmaking server with it previously), but i'd like to do this with haxe if possible.  it's very convenient to have a set up where the server and client can share relevant pieces of code, not to mention less technologies typically means less points of failure. And from a share-ability standpoint, someone interested in picking up my haxe net code to build a game wouldn't have to learn node to tweak the matchmaking server since it'd all be written in haxe.

@Rammserker
if you have a look at the UdpSocket source, it looks like it's non-functional (it throws an error right when you try to create a UdpSocket instance) - https://github.com/HaxeFoundation/haxe/blob/development/std/sys/net/UdpSocket.hx

I'd love it if haxe's built-in UdpSocket class actually worked.  It's surprising that it doesnt'.

Dion Whitehead Amago

unread,
Jul 2, 2015, 6:13:48 PM7/2/15
to haxe...@googlegroups.com


On Thursday, 2 July 2015 14:45:04 UTC-7, Chase de Languillette wrote:
@Dion - 
I am aware of node (and have made a matchmaking server with it previously), but i'd like to do this with haxe if possible.  it's very convenient to have a set up where the server and client can share relevant pieces of code, not to mention less technologies typically means less points of failure. And from a share-ability standpoint, someone interested in picking up my haxe net code to build a game wouldn't have to learn node to tweak the matchmaking server since it'd all be written in haxe.


Yeah that's what I meant, and that's what I do: write Haxe code that compiles to Javascript that is run with Node, that shares code with the client. Not plain Javascript. 

Chase de Languillette

unread,
Jul 2, 2015, 11:27:27 PM7/2/15
to haxe...@googlegroups.com
sounds interesting. is that through https://github.com/dionjwa/nodejs-std ? are there any good resources explaining how this works? i really have no idea how i am supposed to use this library.

Does anyone else know how to solve my original problem?

Andreas Mokros

unread,
Jul 3, 2015, 3:19:21 AM7/3/15
to haxe...@googlegroups.com
Hi.

On Thu, 2 Jul 2015 14:45:04 -0700 (PDT)
Chase de Languillette <chase.dela...@gmail.com> wrote:
> if you have a look at the UdpSocket source, it looks like it's
> non-functional (it throws an error right when you try to create a
> UdpSocket instance)

It seems to be implemented in neko only at the moment:
https://github.com/HaxeFoundation/haxe/blob/development/std/neko/_std/sys/net/UdpSocket.hx

Did you try this?

--
Mockey
Reply all
Reply to author
Forward
0 new messages