I am looking for a simple way to see if a remote UDP port is open on a server
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
BEWARE that several firewalls/network setups/IDS etc. might influence the result… the following method is NOT 100% reliable but it is the only method possible with UDP IMHO (since UDP is connectionless).
You can use
UdpClient, set a receive timeout on the underlying socket, make a connection to that remote server/port,Sendsome small message (byte[]!) and callReceive.IF the port is closed you get an exception saying that the connection was forcibly closed (
SocketExceptionwithErrorCode10054 =WSAECONNRESET)… which means the port is NOT open.Otherwise you either receive an answer OR a timeout exception – both should be interpreted as “the UDP port is open”.