?
Solved

How can I free a port which was occupied by the old deaded progam?

Posted on 2002-04-17
9
Medium Priority
?
329 Views
Last Modified: 2012-05-04
  I develope a service program as a server which bind some udp ports. the system show failed message when sometime I stop the service from the service manager. And then the service is stoped, but the ports it used are not free. When I run the service again, the 10048 Error occurs, which means "the address and port have been used". How can I free those kind of ports.
0
Comment
Question by:Iaskyou
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
  • 2
  • +1
9 Comments
 
LVL 16

Expert Comment

by:SteveJ
ID: 6947982
Depending on how the port connection failed, you may need to reboot to recover the port and the mbuf space. On one of the AIX systems here I have to craft a reset packet and send it as if it were actually coming from the connected machine.

What OS?

Good luck.
Steve
0
 
LVL 24

Expert Comment

by:SunBow
ID: 6949052
0
 
LVL 24

Expert Comment

by:SunBow
ID: 6949116
sounds like either bad OS (services not communicating with each other) or not waiting long enough for everything to sync back up.

> How can I free those kind of ports

Don't. Or rather, why?

Sounds like an ungraceful shutdown, or one that needs more grace.

Almost makes me want to know just which ports....

> I develope a service program as a server which bind

If it all began with your own development, then possibly you still have the control there. Whatever you open - try to close before exit (exit process should do it) (system should also detect the interruption, and run the graceful exit, not the one for debugging). Whatever you bind, unbind prior to exit.

Until then, I think the soft reboot is the quickest path to recovery.
0
Supports up to 4K resolution!

The VS192 2-Port 4K DisplayPort Splitter is perfect for anyone who needs to send one source of DisplayPort high definition video to two or four DisplayPort displays. The VS192 can split and also expand DisplayPort audio/video signal on two or four DisplayPort monitors.

 
LVL 16

Expert Comment

by:SteveJ
ID: 6949120
. . . must be nice to work in an environment where you can just reboot to fix things . . .


Steve
0
 

Author Comment

by:Iaskyou
ID: 6949412
oh, sorry, I forget reporting the OS.
win2000.
0
 

Author Comment

by:Iaskyou
ID: 6949415
The machine is worked as server. So it can not be rebooted oftenly.
0
 
LVL 24

Expert Comment

by:SunBow
ID: 6950523
Generally, for our production servers, we do not make a practise of stopping Win2K services, preferring what stability we can achieve.
0
 
LVL 1

Accepted Solution

by:
swapsthegreat earned 150 total points
ID: 6950527
in your server program, when u create a socket and bind it to a particular port, this problem occurs.
To avoid this use the setsockopt() function to set socket level options to free the bound port immediately.

On Unix systems the call would be

setsockopt(sockdescr,SOL_SOCKET,SO_REUSEADDR,&on,sizeof(int));


sockdesc is socket descriptor
SOL_SOCKET says that options are set at socket level
SO_REUSEADDR allows u to reuse address and port
on is integer which is 1(to set).

Dont know much bout windows programming but i hear it is nearly the same
0
 
LVL 24

Expert Comment

by:SunBow
ID: 6950583
yeah, but a little tricky, and incompleteness can down all ports. not so good for someone's production server(s)
0

Featured Post

Moving data to the cloud? Find out if you’re ready

Before moving to the cloud, it is important to carefully define your db needs, plan for the migration & understand prod. environment. This wp explains how to define what you need from a cloud provider, plan for the migration & what putting a cloud solution into practice entails.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

WARNING:   If you follow the instructions here, you will wipe out your VTP and VLAN configurations.  Make sure you have backed up your switch!!! I recently had some issues with a few low-end Cisco routers (RV325) and I opened a case with Cisco TA…
Make the most of your online learning experience.
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question