Network module problem
Mon, 3 Mar 2003 08:10:57 -0500
Hello. I'm running into a problem with the Network module, which I suspect
is pretty easy to fix, but am not sure how to best do so.
The problem is that "accept" fails when the reverse DNS fails, with the
Fail: does not exist
Reason: no such host entry
I'm not sure how to get around this. I don't actually need the hostname of
the client, and would be happy to just substitute its IP address in that
field, but I'm not sure how to do that.
If I understand correctly (which I may not), if I were to catch this
connection with code like:
(myh,_,_) <- accept s `catch` ...
there would be no way to actually get the handle itself from the
connection, which seems to imply that I'll have to go into the
Network.Socket module and use the lower level code (which looks like it
would be straightforward). However, it seems that this is a simple enough
(and presumably common enough) problem that there should be a more elegant
solution which would allow me to use the high level interface.
Is there any way to `catch` the exception within getHostByAddr, and
substitute the IP address for the output of that function? (I'll admit,
I've never thoroughly understood exceptions in any language, in the sense
of understanding how really to use them right.)
Also, what if I just didn't care about the hostname? That seems like a
common enough case that you wouldn't always want to do a reverse DNS lookup
on every accept. Does that just mean you would have to use the low level