I’m looking at using UDPSocket in my game, I feel like I’m close to getting it to work, however its simply saying “Not available on this platform” for CPP, and Custom(std@socket_recv_from) using neko. Anyone have any idea? Its hard to believe it would be thrown into the Haxe API non-working.
Heres my non-working code, server:
package;
import sys.net.UdpSocket;
import sys.net.Host;
import haxe.io.Bytes;
import haxe.io.Bytes.ofString;
import sys.net.Address;
class NetworkServer{
public static var value:String = "Hello";
public static var udpsocket:UdpSocket;
public function new(){
udpsocket = new UdpSocket();
var localhost:Host = new Host(Host.localhost());
//udpsocket.bind(localhost,4000);
}
public function getValue():String{
var receiveBytes:Bytes = ofString("");
var receiveAddress:Address = new Address();
var funk = udpsocket.readFrom(receiveBytes,0,8,receiveAddress);
return value;
}
}
Client:
package;
import sys.net.UdpSocket;
import sys.net.Host;
import haxe.io.Bytes;
import haxe.io.Bytes.ofString;
import sys.net.Address;
class NetworkClient{
public static var value:String = "SlamDunk";
public static var udpsocket:UdpSocket;
public function new(){
udpsocket = new UdpSocket();
var localhost:Host = new Host(Host.localhost());
var bytes:Bytes = ofString(value);
var address:Address = new Address();
address.host = 2130706433;
address.port = 4000;
var sendPack:Int = udpsocket.sendTo(bytes,0,8,address);
}
}