any way to close socket

I have written a socker program. I have executed that program many times without closing the socket. So I want to find which all sockets binded with which file descriptor.

Is there any way to close those socket, which have been opened in that program's execution.

please help me!..

You can close a socket using shutdown(3SOCKET). Check the man page for arguments to pass in.

Are you using the same port to bind?You can use the netstat command to find the state of the port.

Thanks
Nagarajan G

Thank you,

I can find which ports has been still opened using that netstat function. but i want to close those ports. because my program will try to create the socket on the same port. if that port is already opened means, system cant create the socket or bind.

Can you tell me, how to close those socket ports.

Is there any way to close those ports which are left by the program to close.

Thanks in Advance.