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.