Well, yeah.
Pike v7.5 release 7 running Hilfe v3.5 (Incremental Pike Frontend)
Stdio.File f = Stdio.File(); f->connect("::1", "ftp");
(1) Result: 1
f->query_address();
(2) Result: "::1 21"
f->query_address(1);
(3) Result: "::1 4396"
I expect we'll still need a way to specific protocol family when calling open_socket() directly though, since open_socket() can be used to create the socket without actually disclosing either target or destination address yet. The question is how to specify it. Mareks patch adds a third argument, which seems like the logical choice at first, however it has undesired side effects:
f->open_socket(0,0);
binds the socket to any port on any interface, while
f->open_socket();
creates the socket _without_ binding it. By making the family the third argument, it becomes impossible to specify the family without binding the socket.
We could of course say that if the third argument is given, the first two are disregarded and the socket is not bound, since it's possible to bind the socket manually with a call to ->bind() afterwards if so desired. But having two dummy arguments isn't very nice either...
/ Marcus Comstedt (ACROSS) (Hail Ilpalazzo!)
Previous text:
2003-04-23 23:03: Subject: Re: IPv6 diff for Pike 7.5.7 (today's snapshot)
To me, it seems a lot cleaner to just give it an address, and have the code examine the address to figure out which address family it is.
That's how it works now after Marcus Comstedts latest changes, I believe.
/ Martin Nilsson (har bott i google)
On Thu, Apr 24, 2003 at 01:20:01AM +0200, Marcus Comstedt (ACROSS) (Hail Ilpalazzo!) @ Pike (-) developers forum scribbled: [snip]
I expect we'll still need a way to specific protocol family when calling open_socket() directly though, since open_socket() can be used to create the socket without actually disclosing either target or destination address yet. The question is how to specify it. Mareks patch adds a third argument, which seems like the logical choice at first, however it has undesired side effects:
f->open_socket(0,0);
binds the socket to any port on any interface, while
f->open_socket();
creates the socket _without_ binding it. By making the family the third argument, it becomes impossible to specify the family without binding the socket.
In the current code indeed.
We could of course say that if the third argument is given, the first two are disregarded and the socket is not bound, since it's possible to bind the socket manually with a call to ->bind() afterwards if so desired. But having two dummy arguments isn't very nice either...
Indeed. We could also use -1 for the first argument to make the special case, I guess.
marek
Good suggestion. Port=0 => bind any port, Port=-1 => bind no port. Seems to fit in rather nicely.
/ Marcus Comstedt (ACROSS) (Hail Ilpalazzo!)
Previous text:
2003-04-24 01:29: Subject: Re: IPv6 diff for Pike 7.5.7 (today's snapshot)
On Thu, Apr 24, 2003 at 01:20:01AM +0200, Marcus Comstedt (ACROSS) (Hail Ilpalazzo!) @ Pike (-) developers forum scribbled: [snip]
I expect we'll still need a way to specific protocol family when calling open_socket() directly though, since open_socket() can be used to create the socket without actually disclosing either target or destination address yet. The question is how to specify it. Mareks patch adds a third argument, which seems like the logical choice at first, however it has undesired side effects:
f->open_socket(0,0);
binds the socket to any port on any interface, while
f->open_socket();
creates the socket _without_ binding it. By making the family the third argument, it becomes impossible to specify the family without binding the socket.
In the current code indeed.
We could of course say that if the third argument is given, the first two are disregarded and the socket is not bound, since it's possible to bind the socket manually with a call to ->bind() afterwards if so desired. But having two dummy arguments isn't very nice either...
Indeed. We could also use -1 for the first argument to make the special case, I guess.
marek
/ Brevbäraren
On Thu, Apr 24, 2003 at 01:45:01AM +0200, Marcus Comstedt (ACROSS) (Hail Ilpalazzo!) @ Pike (-) developers forum scribbled:
Good suggestion. Port=0 => bind any port, Port=-1 => bind no port. Seems to fit in rather nicely.
Also, Martin reminded me about something else. The patch I've sent includes code to set the default family when creating sockets. Another feature is that it is possible to have the code automatically switch the default family when first non-default family address is created. That should pretty much cover all the cases,
marek
And again 0 gets another meaning then the no-argument-at-all. :-)
/ Mirar
Previous text:
2003-04-24 01:40: Subject: Re: IPv6 diff for Pike 7.5.7 (today's snapshot)
Good suggestion. Port=0 => bind any port, Port=-1 => bind no port. Seems to fit in rather nicely.
/ Marcus Comstedt (ACROSS) (Hail Ilpalazzo!)
wasn't that the case already before?
greetings, martin.
Yes. Which was exactly why we needed to add the -1 variant in face of a new, orthogonal, third argument.
/ Marcus Comstedt (ACROSS) (Hail Ilpalazzo!)
Previous text:
2003-04-24 09:16: Subject: Re: IPv6 diff for Pike 7.5.7 (today's snapshot)
wasn't that the case already before?
greetings, martin.
/ Brevbäraren
pike-devel@lists.lysator.liu.se