Binding twice on the same ip/port pair became success
Hi,
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.
Fun1()
{
..........
fd1 = socket (AF_INET, SOCK_DGRAM, 0);
setsockopt(fd1, SOL_SOCKET, SO_REUSEADDR, &optval, sizeof (optval))
then called bind...
}
Fun2()
{
fd2 = socket( AF_INET, SOCK_DGRAM, IPPROTO_UDP );
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 127.0.0.1:9897 0.0.0.0:* 5011/abc.vx
udp 0 0 127.0.0.1:9897 0.0.0.0:* 5011/abc.vx
Please help me understanding this behavior, how data from two different sockets are read?
Thanks,
Srik,
|