1

i have a problem. I run a TCP server in linux. I close the socket by close(socket) call. But when I try to rebind again, bind call fails with errno 98 => port is already binded. How should i unbind that socket?

Erkil1452
  • 11
  • 2
  • Might this help?: http://stackoverflow.com/questions/2208581/socket-listen-doesnt-unbind-in-c-under-linux – Bart May 06 '11 at 09:09

2 Answers2

2

You have to set SO_REUSEADDR option on the socket, see here.

Code Painters
  • 7,175
  • 2
  • 31
  • 47
0

You can try setting the SO_REUSEADDR socket option, see this question for some discussion.

Community
  • 1
  • 1
unwind
  • 391,730
  • 64
  • 469
  • 606