Visit Jeremy's Blog.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 01-27-2016, 08:47 AM   #1
LQ Newbie
Registered: Jan 2016
Posts: 1

Rep: Reputation: Disabled
Binding twice on the same ip/port pair became success


I observed one instance in my program, where 2nd bind on same ip/port pair became success instead of failure.
I have made below set socket options before bind.

fd1 = socket (AF_INET, SOCK_DGRAM, 0);
setsockopt(fd1, SOL_SOCKET, SO_REUSEADDR, &optval, sizeof (optval))
then called bind...

setsockopt(fd2, SOL_SOCKET, SO_REUSEADDR, (char*)&unOptVal, sizeof(unOptVal)))
then called bind.......
i am expecting 2nd bind call to be failed, but it became success.
And output of netstat command displays two instances as below

# netstat -apn |grep -i 9897
udp 0 0* 5011/abc.vx
udp 0 0* 5011/abc.vx

Please help me understanding this behavior, how data from two different sockets are read?

Old 01-27-2016, 06:20 PM   #2
Senior Member
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,870

Rep: Reputation: 1487Reputation: 1487Reputation: 1487Reputation: 1487Reputation: 1487Reputation: 1487Reputation: 1487Reputation: 1487Reputation: 1487Reputation: 1487

Don't do that.

Personally, I don't know WHY this is there, as it allows for significant security problems.

The security problem is that two different users can connect to the same port/address and get each others data.

It is intended to allow a server to rebind to a socket in case the previous server has died and the socket is still open until the timeout occurs... Unfortunately, it also allows OTHER servers to also connect.... and leave security problems in its wake.

A user application/server doing this allows multiple users to connect... and the corresponding security failures happen again.

And yes, I got bit by this - fortunately, local user testing identified the problem so I could remove it before a general release happened.

Last edited by jpollard; 01-27-2016 at 06:22 PM.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
binding port mokku Linux - Newbie 4 11-10-2007 06:51 PM
Azureus port binding G00fy Linux - Networking 0 07-18-2006 03:15 AM
error binding address/port blackzone Linux - Networking 1 09-03-2004 03:23 AM
PsyBNC not binding on port 80. Adam15906 Linux - Software 1 06-10-2004 12:24 PM
Socket binding to port problems Xris718 Linux - General 0 07-10-2003 02:04 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:40 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration