c++ - Can't connect to a port, but netstat shows what port LISTENING -


while trying connect error:

"no connection made because target machine actively refused it."

but netstat shows:

tcp    0.0.0.0:my_port           my_pc:0        listening 

only problem can think app bound port under step-by-step debugging, paused. how can workaround it.

basicly need know somehow if bound port. (i can't use so_exclusiveaddruse)


i think can't connect because app uses port in debug paused mode, so, first time connect doesn't "clear connection".

if want check if given port in use, can bind() , check failure. if don't want create socket , bind it, can instead loop through arrays returned gettcptable(), gettcptable2(), gettcp6table(), gettcp6table2(), getudptable(), , getudp6table() functions. table2() not report ips , ports in use, process ids own them (from can access additional information, file names). these same functions netstat uses internally information.


Comments

Popular posts from this blog

Eclipse formatter for java ending braces -

ruby - Nesting modules inside of a Rails eninge gem -

java - Are there any classes that implement javax.persistence.Parameter<T>? -