Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Q: Is it possible to detect wether the server:port is available? #1

Open
vdevos opened this issue Apr 29, 2013 · 2 comments
Open

Q: Is it possible to detect wether the server:port is available? #1

vdevos opened this issue Apr 29, 2013 · 2 comments

Comments

@vdevos
Copy link

vdevos commented Apr 29, 2013

I'm using statsd-c-client in a C++ project of mine and I've been trying to add some functionality in order to detect if statsd is listening from server-ip on port. But since the socket is setup with SOCK_DGRAM and IPPROTO_UDP it's simply not possible to detect whether the service is at all listening/receiving (no sendto failures)

I've also tried to setup a temporary socket type SOCK_STREAM and added a signal(SIGPIPE, sigpipe_handler) as a sig-handler. Then normally, when you would write (and no service was listening) you would get a pipe error which could serve as a indicator that statsd is not active as a service. The problem is that statsd is not supporting these kind of socket connections (which I can understand) but making it almost impossible to solve..

You think there might be a other way to detect this?

@vdevos vdevos closed this as completed Apr 29, 2013
@vdevos vdevos reopened this Apr 29, 2013
@romanbsd
Copy link
Owner

This is what's written in nmap docs, I don't know if it helps you:

"UDP recvfrom() and write() scanning : While non-root users can't read port unreachable errors directly, Linux is cool enough to inform the user indirectly when they have been received. For example a second write() call to a closed port will usually fail. A lot of scanners such as netcat and Pluvius' pscan.c does this. I have also noticed that recvfrom() on non-blocking UDP sockets usually return EAGAIN ("Try Again", errno 13) if the ICMP error hasn't been received, and ECONNREFUSED ("Connection refused", errno 111) if it has. This is the technique used for determining open ports when non-root users use -u (UDP). Root users can also use the -l (lamer UDP scan) options to force this, but it is a really dumb idea."

@vdevos
Copy link
Author

vdevos commented Apr 29, 2013

Thanks, I'm going to look into that and if possible push a patch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants