473,405 Members | 2,176 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Force closing UDP port

Hi,

I am using UDP protocol for communication in my application in C#.
I am using UdpClient class.
The problem is that sometimes the UDP port remains opened/stucked even
if I close the application and restart the computer. Hence, I can't
start this port again and I get an exception.

So I would like to know if there is any way to force closing this port
from the application in case it's already opened.

Thanks,
Pavel

Oct 31 '06 #1
5 6626
"pa**********@gmail.com" <pa**********@gmail.comwrites:
The problem is that sometimes the UDP port remains opened/stucked even
if I close the application and restart the computer. Hence, I can't
start this port again and I get an exception.
A socket can never survive a system restart, so the issue must be
another application using this port or another instance of your
application already started.

Best regards,
Martin
Oct 31 '06 #2

Martin Carpella wrote:
"pa**********@gmail.com" <pa**********@gmail.comwrites:
The problem is that sometimes the UDP port remains opened/stucked even
if I close the application and restart the computer. Hence, I can't
start this port again and I get an exception.

A socket can never survive a system restart, so the issue must be
another application using this port or another instance of your
application already started.

Best regards,
Martin
1. I suppose that it happens because of abnormal flow of my
application.

2. May be there is some external DOS/Windows command which can reset
needed port.

Oct 31 '06 #3
Even restart all network service will be good enough, it should close
all stuck ports.
I have tried to find such a service in services but I didn't find any
that helps.

Oct 31 '06 #4

"Martin Carpella" <ma*************@gmx.netwrote in message
news:87************@msgid.carpella.net...
"pa**********@gmail.com" <pa**********@gmail.comwrites:
>The problem is that sometimes the UDP port remains opened/stucked even
if I close the application and restart the computer. Hence, I can't
start this port again and I get an exception.

A socket can never survive a system restart, so the issue must be
another application using this port or another instance of your
application already started.
Yes.

Use "netstat -a -o -p UDP -n" to find out what process has the port open.
Then configure that application to not use your port.
>
Best regards,
Martin

Oct 31 '06 #5
"pa**********@gmail.com" <pa**********@gmail.comwrites:
1. I suppose that it happens because of abnormal flow of my
application.
Sorry, cannot elaborate on this issue ;)
2. May be there is some external DOS/Windows command which can reset
needed port.
You could use WMI to find out which process has this port open and try
to kill this process, but this would be a quite "unfriendly" solution to
the problem. But at least it could help you debug by finding the
responsible process. Unfortunately I am not really well-versed in WMI,
so I cannot provide you with a code example.

Best regards,
Martin
Oct 31 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Mathew | last post by:
I am looking to write a program with Microsoft Visual Basic 6 that writes out to the com port. After the inital Connection. I will be connecting at 9600, 8 data bits, with hardware flow control. ...
1
by: Nick Zdunic | last post by:
I have a scenario where I'm sending data out an IP port to a server. The data would go out like this: 012345689 One one scenario I'm sending several messages to the server in very quick...
10
by: Jako Menkveld | last post by:
I'm building a relatively simple client-server app. One of the functions of the client is to notify the server when it terminates, this all works fine. The problem comes in when the server is...
2
by: Daneel | last post by:
The following code gets attributes from an LDAP server. It works several times, but then returns a "server is not operational" error for all subsequent calls. A "netstat -na" on the Windows 2003...
4
by: Paul | last post by:
I want to run MySQL on server but it only be accessible to programs on localhost. I see that port 3306 is open on server so I need to close it. How do I do that while keeping it available to...
3
by: ricolee99 | last post by:
Hi Everyone, I'm using the System.IO.Ports.SerialPort component to attempt to kill an existing component opened by another application. I use the following code: SerialPort serialPort = new...
13
by: Rob | last post by:
Hi all, I am fairly new to python, but not programming and embedded. I am having an issue which I believe is related to the hardware, triggered by the software read I am doing in pySerial. I...
4
by: O.B. | last post by:
I have a socket configured as TCP and running as a listener. When I close socket, it doesn't always free up the port immediately. Even when no connections have been made to it. So when I open...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.