>Hi Steve,
>
>I know its pretty easy from C, the question is whether it is easy
>from Unicon, or whether we need to add a little something here.
>For example, is the hostname or IP you connected to stored in the
>"filename" field and therefore obtainable using image(net) or whatever?
>Somehow I bet that's wishful thinking. Or stat() could include peer IP
>info in a field; I don't know whether it does. Anyhow, thanks for your
>implementation suggestion, someone may need to code it up.
>
>CJ> I was hoping Shamim would know how the server checks the client's IP#.
>
>SL> I thought maybe I was confused. Unless I'm missing something, both
>SL> accept(2) and recvfrom(2) fill a sockaddr with the address of the
>SL> sender. If you are using a connection-oriented protocol you can also
>SL> use getpeername(2) any time to get a sockaddr for the other side.
UTSL. For UDP, the peer address is available from what receive()
returns (see tests/posix/udp.icn).
For TCP, it looks like the peer address is retrieved but then thrown
away and just the file is returned (rposix.r:sock_listen()). That
actually makes sense, it would be a bad idea to impose a DNS lookup on
every accept for programs that don't care (and what do you do when the
lookup fails?) Just wire getpeername to the function/operator of your
choice.
If image() is already the idomatic way to get a filename, then that
would be good, but I suspect that the idomatic way to get a filename is
to just remember what it was when you called open() :-). I actually
lean toward where(). Graphics already does something with where
(although I'm not exactly sure what, pollctr = pollctr / 2 + 1?), and
Network apparently was going to do something with it eventually.
Perhaps where() could be extended to return other information about a
file if people find that useful. Ruby for example has an expand_path
method that returns the full path to a file. Maybe Unicon could have:
# In /src/unicon/cvs/unicon/src/runtime
f := open("../h/posix.h")
p := where(f, "path") # "../h/posix.h"
p := where(f, "fullpath") # "/src/unicon/cvs/unicon/src/h/posix.h"
f := open(":1234", "na")
p := where(f, "peerip") # 0x7f0001
p := where(f, "peername") # "localhost"
Steve
_______________________________________________
Unicon-group mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/unicon-group