mIRC Home    About    Download    Register    News    Help

Print Thread
Udp socket and ipv6 #269446 02/10/21 05:36 PM
Joined: Jul 2006
Posts: 3,807
W
Wims Offline OP
Hoopy frood
OP Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 3,807
Probably a bug but I'm posting here just in case.
I have a game which works with udp, so far the server was only running on an ipv4 connection, For a while now I have been connected via my phone acting as wifi... which gives me ipv6.
With 7.67 just released I ran the game to see if it worked on that new version, but it didn't work. I had hardcoded 127.0.0.1 for connecting a client locally when you were the server, so I fixed that to be based on $iptype($ip), which solved the issue for tcp ( the game also use tcp; if it's ipv6 I changed the loopback address to ::1 (or 0:0:0:0:0:0:0:1))
Now for udp, I can't get anything to work, using ::1 or 0:0:0:0:0:0:0:1 as the ip address there does not work at all, the server is created with
Code
/sockudp -k udpserversocketname <port>
where <port> is any valid port. And here is an associated on udpread event:
Code
on *:udpread:udpserversocketname:{
  echo -sg received info from $sock($sockname).saddr $sock($sockname).sport
}

With a simple client being like:
Code
/sockudp tempclient 0:0:0:0:0:0:0:1 <port> some data


Can anyone get udp socket to work with ipv6 connectivity?

Last edited by Wims; 02/10/21 09:17 PM.

Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net
Re: Udp socket and ipv6 [Re: Wims] #269450 03/10/21 09:15 AM
Joined: Dec 2002
Posts: 4,999
Khaled Offline
Hoopy frood
Offline
Hoopy frood
Joined: Dec 2002
Posts: 4,999
You will need to use -d to bind the listening socket to an IPv6 address, otherwise it will default to IPv4.

Re: Udp socket and ipv6 [Re: Khaled] #269452 03/10/21 11:47 AM
Joined: Jul 2006
Posts: 3,807
W
Wims Offline OP
Hoopy frood
OP Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 3,807
Ah ok, thanks for the reply.

May I ask, why did you choose to support ipv6 with -d binding? Because it seems to me that ip version and binding are unrelated, more importantly it means that one cannot send an udp packet on a given adapter/network card using ipv6, because that's what the binding is for, technically, isn't it? Could this be changed so that we can pass an ipv6 just like an ipv4, preserving the binding feature regardless of the ip version? I have never seen anyone use udp, so coupled with ipv6 it must be even more rare, aka I don't think that would break any script.

Edit: /sockopen does not behave like this and accept either version of ip without -d switch, which I hope is a strong argument.

Last edited by Wims; 03/10/21 12:07 PM.

Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net
Re: Udp socket and ipv6 [Re: Wims] #269453 03/10/21 12:35 PM
Joined: Dec 2002
Posts: 4,999
Khaled Offline
Hoopy frood
Offline
Hoopy frood
Joined: Dec 2002
Posts: 4,999
Quote
May I ask, why did you choose to support ipv6 with -d binding?

I didn't. It just happens that the -d switch allows you to bind to an address and this in turn allows you to choose an IPv4 or IPv6 address. Since your script is trying to connect to an IPv6 server, you need to set up an IPv6 listening socket.

/sockopen, as a client command, requires an IP address to connect to. If you specify an IPv4/IPv6 address, it will bind using the appropriate protocol for the IP address type.

/socklisten and /sockudp, when listening for an incoming connection, do not require an IP address. But specifying one with the -d switch will allow you to specify the IP protocol type.

Re: Udp socket and ipv6 [Re: Khaled] #269454 03/10/21 01:09 PM
Joined: Jul 2006
Posts: 3,807
W
Wims Offline OP
Hoopy frood
OP Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 3,807
That makes sense, somehow I thought the binding had to be done when sending the data, not when creating the 'listening' socket, sorry for the misunderstanding, it works.

Last edited by Wims; 03/10/21 02:41 PM.

Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net