Wednesday, October 20, 2010

bind() function failure

Issue description:  bind() function is failed with error code -1.

RCA:[Root Cause Analysis]

  For this issue, I checked why bind () fn is failed.
Usually all the socket functions will return -1 for failure cases.
To know more about why it is failed, We can use WSAGetLastError() fn in case of windows.
But in case of unix/linux, There is no such function.
Instead the error value will be set to "errno" variable. We have to check this errno to know the failure.

Solution:
  I got the the file does not exit error.
Some junk  IP address value is passed to bind() function's input arguments. That is the reason, we observed this error.
I set the IP address as zero before bind() fn [which is working fine for successful cases, for failure cases,we are getting

junk IP addresses]

  I set the IP address to zero to resolve this issue.

 

No comments: