# binding problems

**URL:** <https://community.unix.com/t/binding-problems/167737>\
**Category:** IP Networking\
**Created:** [December 17, 2006, 12:42pm UTC](https://community.unix.com/t/binding-problems/167737 "2006-12-17T12:42:42Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![damn\_bkb](https://community.unix.com/letter_avatar/damn_bkb/32/5_5575768a8748004e209b776fc1b2916d.png) [@damn\_bkb](https://community.unix.com/u/damn_bkb)\
**Post date:** [December 17, 2006, 12:42pm UTC](https://community.unix.com/t/binding-problems/167737/1 "2006-12-17T12:42:42Z")

</div>

i had a problem when using the bind function.. that is when i create a socket and bind it with a address(usually some file name)... when i run it once it goes on fine but the second time it tells a error since there is already a socket file in that name created by my previous run...

but when i use a tcp/ip method, i cant see the socket file at all.. where is that one created..?

---

<div class="post-metadata">

**Author:** ![cbkihong](https://community.unix.com/letter_avatar/cbkihong/32/5_5575768a8748004e209b776fc1b2916d.png) [@cbkihong](https://community.unix.com/u/cbkihong)\
**Post date:** [December 17, 2006, 8:26pm UTC](https://community.unix.com/t/binding-problems/167737/2 "2006-12-17T20:26:35Z")

</div>

Is the previous socket properly close()d? If not, there might be an interval during which the socket may still be "occupied" until it times out. I experience this a lot with server sockets.

---

<div class="post-metadata">

**Author:** ![Perderabo](https://community.unix.com/user_avatar/community.unix.com/perderabo/32/27_2.png) [@Perderabo](https://community.unix.com/u/Perderabo)\
**Post date:** [December 17, 2006, 9:46pm UTC](https://community.unix.com/t/binding-problems/167737/3 "2006-12-17T21:46:03Z")

</div>

Ever notice that inetd never has this problem? [Here is the source code](http://src.opensolaris.org/source/xref/onnv/onnv-gate/usr/src/cmd/cmd-inet/usr.lib/inetd/inetd.c) for the Solaris version of inetd. It does its bind() in the routine called "create\_bound\_socket" (lines 653 - 724) The "secret" is line 671 which is a call to setsockopt to turn on SO\_REUSEADDR.

As long as no process currently is using the port, this is all it takes.
