[X-Post] Determine Local Port Client Application is Listening On.

  • Thread starter Thread starter Ken Wilson
  • Start date Start date
K

Ken Wilson

I have created a socket in a client application and have called
connect on the remote service. How do I determine the port the client
is accepting responses on? Bind was not called on the socket at any
time prior to or after the call to connect. (Winsock2)

Thanks in advance for answers, hints or suggestions

Ken Wilson
Seeking viable IT employment in Victoria, BC
 
That would be getsockname() actually.

--
=====================================
Alexander Nickolov
Microsoft MVP [VC], MCSD
email: (e-mail address removed)
MVP VC FAQ: http://www.mvps.org/vcfaq
=====================================
 
For sure, tnx
Arkady
Alexander Nickolov said:
That would be getsockname() actually.

--
=====================================
Alexander Nickolov
Microsoft MVP [VC], MCSD
email: (e-mail address removed)
MVP VC FAQ: http://www.mvps.org/vcfaq
=====================================

Arkady Frenkel said:
getpeername() on service or getsocketname() on client
Arkady
 
getpeername() on service or getsocketname() on client
Arkady
Thanks for your response. The call to getsockname was indeed the
answer. It was causing me some problems as I was passing in a
sockaddr struct rather than sockaddr_in. Once that was resolved the
port number was available directly as a member of the struct.

Ken Wilson
Seeking viable IT employment in Victoria, BC
 
Just from your answer I see my next fault ( in addition to one Alexander
mention ) : I wrote "getpeername() on service" when need be on "server".
That IMHO because my current games with windows communication foundation
( a.k.a "Indigo" )
Arkady
 
Back
Top