I opened a port in my socket program, if it is a proper shutdown then the port is clossing properlly. When my program got aborted then the port is not clossing. it is keep on in the Listen status only. how to close the Opened port using another program or how to handle this? I've only the port number eg:1101.
a) Here I assume that you assign the port numbers manually and the assignment is not done by the OS.
b) /proc/net/tcp or /proc/net/udp contains the details of sockets you are using.
c) Parse the above file and store the process ids of the port numbers which are still open.
d) In your program do an execv or system("kill -9 of the pid") corresponding to the open port
I guess I would approach your problem like this. Though there could be other way as well.