# non-standard behavior of socket_recvfrom()

- Thread: https://externals.io/message/17572
- Original archive: https://news-web.php.net/php.internals/17572
- Started by Ron Korving on 2005-08-07T16:18:26+00:00
- Messages: 1
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #17572 — Ron Korving — 2005-08-07T16:18:26+00:00

URL: https://externals.io/message/17572#17572

Hi,

This may be an odd suggestion/request, and nothing in the line of what's
currently hot around here (PHP 5.1 that is), but I'm making it anyway:

The current behavior of `socket_recvfrom()` (/etc/sockets/socket.h) on a
connection error, is that it frees the buffer (recv_buf), throws an error
and returns from the function. I'd like to suggest that more correct
behaviour would be to use the buffer before returning. As far as I know,
even on failure, the buffer can be used to extract information on why the
connection was refused.

I came upon this while I was trying to implement a traceroute algorithm,
which should be pretty simple, but seems impossible because of this socket
behavior in PHP. The change in the code of `socket_recvfrom()` would be very
minimal. I would suggest a patch myself, but the problems are that I don't
know how and I don't know nearly enough about the PHP engine to write solid
code for it (maybe I should work on that).

Ron
