Hi, is there any way to check if a local UDP port is bound other than actually trying to bind? I read on MSDN that a port that has been bound is not immediately available again for bindung after closesocket. Unfortunately I can't do this in a single step (like try to bind and leave it) but I need to test first, so what's the best way to do that? Thanks very much for any help, Matthias Moetje ------------------------------------- TERASENS GmbH Augustenstrae 24 80333 Munich, GERMANY ------------------------------------- Fon: +49 89 143370-0 Fax: +49 89 143370-22 e-mail: moetje at terasens dot com www: www.terasens.com -------------------------------------
You can check that with GetUdpStatistics(Ex)/GetTcpStatistics(Ex) from IPHLPAPI. Really by default the time socket still in is 240s ( look at documentation for HKEY_LOCAL_MACHINE\System\CurrectControlSet\services\Tcpip\Parameters\\TcpTimedWaitDelay), to overcome the problem sesockopt() with SO_REUSEADDR have to be used. Arkady "Matthias Moetje [MVP]" wrote in message news:O4dK80CWGHA.5012@TK2MSFTNGP05.phx.gbl... > Hi, > > is there any way to check if a local UDP port is bound > other than actually trying to bind? > > I read on MSDN that a port that has been bound is > not immediately available again for bindung after closesocket. > > Unfortunately I can't do this in a single step (like try > to bind and leave it) but I need to test first, so what's > the best way to do that? > > Thanks very much for any help, > > Matthias Moetje > ------------------------------------- > TERASENS GmbH > Augustenstrae 24 > 80333 Munich, GERMANY > ------------------------------------- > Fon: +49 89 143370-0 > Fax: +49 89 143370-22 > e-mail: moetje at terasens dot com > www: www.terasens.com > ------------------------------------- > >
"Matthias Moetje [MVP]" wrote: > is there any way to check if a local UDP port is bound > other than actually trying to bind? Have you tried getsockname()? --gv
Hi, "Matthias Moetje [MVP]" wrote in message news:O4dK80CWGHA.5012@TK2MSFTNGP05.phx.gbl... > Hi, > > is there any way to check if a local UDP port is bound > other than actually trying to bind? I'm just curious ... why would you want to know if a port is bound or not other than to bind it? regards, Alexandru. > > I read on MSDN that a port that has been bound is > not immediately available again for bindung after closesocket. > > Unfortunately I can't do this in a single step (like try > to bind and leave it) but I need to test first, so what's > the best way to do that? > > Thanks very much for any help, > > Matthias Moetje > ------------------------------------- > TERASENS GmbH > Augustenstrae 24 > 80333 Munich, GERMANY > ------------------------------------- > Fon: +49 89 143370-0 > Fax: +49 89 143370-22 > e-mail: moetje at terasens dot com > www: www.terasens.com > ------------------------------------- > >
this post might be helpful to you http://www.codeguru.com/forum/archive/index.php/t-188092.html Enumerating TCP ports and mapping them to PID (for XP)