Re: Bind fails with an error port is in use.



avakharia_ibsdev@xxxxxxxxx <avakharia_ibsdev@xxxxxxxxx> wrote:
I have used SetSockOpt - SO_REUSEADDR before bind function.

Can you post this area of code? There are couple of minor
variations of theme that might be significant.

In particular case i am getting SetSockOpt functions completes with No
error but still bind fucntion fails with error that port is in use.

That may well be the case - as I think you are aware, REUSEADDR only
bypasses some checks when binding to a port. If the port is indeed
bound by another process, the second bind will still fail.

Case is i have three users of my MAC machine. User A logged
in,Application is successfull to bind the port and client also gets
connected successfully. Now i m closing my Client server application
and switching to another user and try to run my server application.
Here my socket cannot able to bind on port and fails with an error
that it is in Use. Suprisingly if i try with after 1 or 2 minutes it
gets binded successfully.

It is here bit difficult to judge why this is happing only when
switching the user. As if I run my application number of time in same
user it will never give me such error.

Wow, that's interesting. I've never heard of multiple users causing
problems, but then again I'd say that would be a rare situation.
Generally anything that binds to a port and listens as a server
will be run by one superuser and only once. Not that that should
prevent you from doing what you want.

The 1-2 minutes thing certainly does sound like REUSEADDR should
fix it up though.

Either i force terminate the
process or close it smoothly.

Ah, but does the process close() the socket it bound to?

I don't think this is a MACOSX problem or Objective - C problem. I
still looking into my code and find the solution of this.

Post some relevant code if you want a few more eyes to help you
out.

--
*--------------------------------------------------------*
| ^Nothing is foolproof to a sufficiently talented fool^ |
| Heath Raftery, HRSoftWorks _\|/_ |
*______________________________________m_('.')_m_________*
.



Relevant Pages

  • Re: Java Error
    ... number corresponds to a particular "server" application but it doesn't have ... Normally TELNET can be found when you connect to port 23 from ... The bind() call references the structure mentioned above. ... specify that port and IP address in the destination fields of the IP header ...
    (bit.listserv.ibm-main)
  • Re: LDAP Lookup failure
    ... bind but LDP can, then that should clear ldap for you. ... ldap to bind to the server. ... When it fails can you also do a forward and reverse lookup of the host name ...
    (microsoft.public.windows.server.active_directory)
  • Re: Good security related article
    ... A HTTP server has to bind to port 80, ... a process can give up root privileges ...
    (borland.public.delphi.thirdpartytools.general)
  • Re: FreeBSD 7.1 and BIND exploit
    ... If you have a server that is running ... BIND, update BIND now. ... Make sure that you are not specifying a port via ... queries behind a one-to-many NAT using pf, ...
    (freebsd-stable)
  • RE: The process cannot access the file...
    ... When you launch IIS 6.0 on a .NET Server machine, ... If an application is already using port 80 on any IP address and you then ... Once this has happened no additional processes can bind to port 80 on any ...
    (microsoft.public.inetserver.iis)