Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

This question is more for my own education than to solve any problem.

I am running a VPS at linode w/ lighttpd and PHP 5.3.13 via fast-cgi.

When I list internet connections, I get this strange creature:

# lsof -i
COMMAND     PID     USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
...
php-cgi   25095 lighttpd   13u  IPv6  75194      0t0  UDP myhostname.com:48192->resolver2.fremont.linode.com:domain

I have never seen a UDP "connection" before? Could someone explain what this sort of UDP connection is-- isn't UDP a connection-less protocol? Does it have something to do with IPv6? (I have set up the IPv6 address of the Linode's local DNS resolver as default, rather than the IPv4 address.)

Secondly, this "connection" has stuck around. Shouldn't all php connections be closed when the fastcgi process completes its task? Lighttpd's status page shows no open connections, and no open fastcgi requests.

CLARIFICATION:

Specifically, I was wondering why lsof lists the destination of the UDP socket here, as it usually does with TCP connections. That's what I have never seen before. Usually, UDP connections appear like this:

# lsof -i
COMMAND    PID     USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
ntpd      1624      ntp   18u  IPv6   2819      0t0  UDP myhostname.com:ntp

...without the destination listed.

Apparently, there is a "connection-oriented" UDP mode. You call connect() on a socket instead of bind(), which allows to use send() and receive() (connection-oriented calls) instead of sendto() and receivefrm(). This will NOT keep the connection open, but it will allocate a port to the connection and keep it active... hence the name - connection-oriented. (from here)

I think that lsof is displaying the destination of UDP connections only for these "connection-oriented" UDP sockets. Is that correct?

share|improve this question

1 Answer 1

lsof shows you the UDP socket (which specifies information like source port, destination address and destination port) that php-cgi is using to talk to the DNS server (not a "connection"). As long as the socket stays open it will show up in your lsof output.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.