Matthias Apitz <guru@unixarea.de> writes:
> 1. In addition to the above code, can I get somehow the connecting client's PID? If
Not in any portable way. If you believe that the offending client is on
the local system, you could try building something involving netstat,
lsof, etc. getpeereid() might be useful too.
> 2. Can I get something out of the buffer of the startup packet?
I'm fairly sure that at the point where the error is thrown, we've
only read the putative length word, so there's nothing buffered.
But sure, you could try to collect whatever is available from the
socket and dump that --- probably a hex dump would be advisable,
because it'll contain \0 bytes. Seems like a good idea.
regards, tom lane