HaxeFoundation / HaxeFoundation/haxe

Cannot send UDP packet to an ipv6 host

Open
#7,297 2 comments 0 reactions 0 assignees View on GitHub
standard library
Dominant language
Haxe
Stars
6.9k
Forks
715
Avg merge
2d 2h
Merged PRs (30d)
11

Description

I am trying to use a client written in haxe to send UDP packets to a server I have written in golang. I am able to get it to work by setting the host ip to "localhost"

This is the working code
```haxe
package;

import sys.net.UdpSocket;
import sys.net.Address;
import sys.net.Host;
import flixel.FlxState;
import flixel.FlxG;
import haxe.io.Bytes;
import cpp.NativeSocket;

class PlayState extends FlxState
{
var testplayer:Player;

var udpSock:UdpSocket = new UdpSocket();
var hostAddr:Address= new Address();

var message:Bytes;
var buffer:Bytes;

override public function create():Void
{
testplayer = new Player(100, 100);

this.add(testplayer);

message = Bytes.ofString("Hi");
buffer = Bytes.alloc(1024);

udpSock.bind(new Host("0.0.0.0"), 6666);

hostAddr.host = new Host("localhost").ip;
hostAddr.port = 9090;

trace(hostAddr.host);

udpSock.sendTo(message, 0, message.length, hostAddr);
message = Bytes.ofString("one");
udpSock.sendTo(message, 0, message.length, hostAddr);
message = Bytes.ofString("two");
udpSock.sendTo(message, 0, message.length, hostAddr);
message = Bytes.ofString("three");
udpSock.sendTo(message, 0, message.length, hostAddr);
message = Bytes.ofString("four");
udpSock.sendTo(message, 0, message.length, hostAddr);
message = Bytes.ofString("five");
udpSock.sendTo(message, 0, message.length, hostAddr);

super.create();
}

override public function update(elapsed:Float):Void
{
super.update(elapsed);

trace(testplayer.getState());

}
}
```
I have not been able to figure out a way to replace "localhost" with the ipv6 address of my server so other clients can access it.

I outlined this issue [Here](https://community.haxe.org/t/connecting-to-a-server-with-ipv6-address/903/3) where I was directed to you guys to open up an issue. Any help on this would be much appreciated.

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the Haxe client’s UdpSocket.sendTo call with the IPv6 server address instead of localhost, using the inline PlayState example as the entry point. Read the sys.net.Address, sys.net.Host, and sys.net.UdpSocket APIs to determine how IPv6 addresses are represented and sent. Done means a client can send UDP packets to the server using its IPv6 address.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
networking
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.