close existing tcp connection in C

Hello. I would like to know how to close an existing tcp socket. I have read some stuff and learned how to create a socket and then close it but have not found anything about how to close an existing tcp socket created by another application. The situation is this: I have an ODBC server running and sometimes it hangs and needs to be reset. The problem is when people still have the client application (Crystal Reports) open, The ODBC server will not restart because the socket it still open, but in a FIN_WAIT state. I have looked at tcpkill.c from dsniff-2.3, but I really do not know what I am looking at. I do not have much C knowledge. Can anyone help me? Thanks

raidzero,

What exactly do you want to know?. tcpkill.c use libpcap to filter some packages directed to the socket that you want to close.

You have to compile tcpkill.c and run it up as a root user in order to close the socket.

Thanks for the reply. I understand that, it's just that tcpkill will terminate all connections, and that is certainly not what I want to do. I would like to kill any sockets using a specific port.

Hi raidzero,

I'm analyzing the tcpkill.c source code and I will try to make some changes to reset only a specific tcp connection. I will let you know if it works as soon as possible.

bye.

wow! than you so much that's awesome

What OS are you using? Some OSes come with the ndd utility which can be used to close a FIN_WAIT'ed socket.

It will be used on AIX 5.3.