Ezio
Ezio

Reputation: 1175

How do I remove a CLOSE_WAIT socket connection?

I have write a simple program using socket in C that create a connect between X86 running windows and ARM running embedded linux(consist of only Busybox and libc).Suddenly this small program could not connect the windows and linux,then I running "netsta -a" found 3 socket's state is CLOSE_WAIT and PID is NULL.So I try to modify “net.ipv4.tcp_keepalive_×” but because busybox has only the basic functions that I could not using /etc/rc.d/init.d/network restart makes the modify take effect.

So I want to know:

  1. how to make the change take effect with Busybox?
  2. how I using socket can avoid the CLOSE_WAIT problem?

Upvotes: 0

Views: 4905

Answers (2)

mirage
mirage

Reputation: 631

You might want to check out: https://github.com/rghose/kill-close-wait-connections

What this script does is send out the ACK which the connection was waiting for.

This is what worked for me.

Upvotes: 0

user207421
user207421

Reputation: 311048

How do I remove a CLOSE_WAIT connection that doesn't belong to any tasks?

As we've established that the process is still running, it does belong to a task. We've also established that the netstat output was a complete red herring.

All you have to do is close the socket. You probably forget to close it after you got the connection failure. It's just a common or garden file/socket descriptor leak.

Upvotes: 1

Related Questions