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

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
 
A

Alexander Nickolov

That would be getsockname() actually.

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

Arkady Frenkel

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
 
K

Ken Wilson

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
 
A

Arkady Frenkel

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top