Re: Final Confusions on Concurrent Server



I certainly misunderstood then (though luckily all of my information is still accurate!). As Chuck Arney said, once you ACCEPT a socket the address structure that is returned contains the IP address and port that the client connected from. (That is, the same information that you would get if you used GETPEERNAME on the socket that is returned by ACCEPT.)

Frank
--

Frank Swarbrick
Applications Architect - Mainframe Applications Development
FirstBank Data Corporation - Lakewood, CO USA
P: 303-235-1403


On 11/4/2009 at 6:09 PM, in message <009e01ca5db4$abfc1000$03f43000$@net>, Joe
Reichman <joereichman@xxxxxxxxxxxxx> wrote:
Seems like I am looking for GETPERNAME after the SELECT to see the port that
the client is using

-----Original Message-----
From: IBM Mainframe Discussion List [mailto:IBM-MAIN@xxxxxxxxxxx] On Behalf
Of Frank Swarbrick
Sent: Wednesday, November 04, 2009 7:34 PM
To: IBM-MAIN@xxxxxxxxxxx
Subject: Re: Final Confusions on Concurrent Server

The SELECT macro returns a bitmap of sockets, with the ones set to 1 (and
not 0) being the ones that been connected to (assuming the socket is a
listener socket). You simply do an ACCEPT of that socket. Your program I
would think already knows what listener sockets are mapped to what port.
But if that is not enough you can simply use GETSOCKNAME service and it will
return to you the local IP address and port number that is assigned to that
socket. This is similar to GETPEERNAME, which returns the remote IP address
and port (rather than the local).

Since your message seemed to be garbled at the end I'm not sure if this is
exactly what you are looking for, but I hope it helps.

I guess the thing that is unclear to many is that the listener socket and
the "connected" socket (that is returned when you ACCEPT on a listener
socket) will always have the same local port. That's why GETSOCKNAME won't
really get you something that you do not already know. On the other hand I
use it (GETSOCKNAME) myself just "because it's there". I guess the one
thing it gives you, I think, is the actual IP address that the remote host
connected to. This could be of interest if you have multiple IP addresses
assigned, and you are simply listening on all of them (ANY_ADDR, or
"0.0.0.0"). But the local port is the port is the port, and does not
change.

Frank



The information contained in this electronic communication and any document attached hereto or transmitted herewith is confidential and intended for the exclusive use of the individual or entity named above. If the reader of this message is not the intended recipient or the employee or agent responsible for delivering it to the intended recipient, you are hereby notified that any examination, use, dissemination, distribution or copying of this communication or any part thereof is strictly prohibited. If you have received this communication in error, please immediately notify the sender by reply e-mail and destroy this communication. Thank you.

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to listserv@xxxxxxxxxxx with the message: GET IBM-MAIN INFO
Search the archives at http://bama.ua.edu/archives/ibm-main.html
.



Relevant Pages

  • Re: Opening up multiple sockets
    ... OS will choose random local port number to connect. ... Local.com is an Apache Linux server. ... but it opens a socket on the *LOCAL* server. ...
    (comp.lang.php)
  • Re: Socket Programming
    ... Antony Sequeira wrote: ... |> The serialized print of the socket obtained by 'ss.accept' ... Local port, Remote address, Remote port}. ...
    (comp.lang.lisp)
  • Re: using protected methods in compact framework
    ... Also note that a remote port and a local port have different values. ... Best regards, ... so as to get the local endpoint of the current connected socket. ...
    (microsoft.public.dotnet.framework.compactframework)
  • Re: How to bind to an already used local port ?
    ... construct B to work on that port and serve as a relay to program A running on some other port. ... I have a program "A" which send UDP packets from a specific local address and local port to another computer on a specific distant port and distant address. ... "Allows socket to bind to an address and port already in use. ...
    (microsoft.public.win32.programmer.networks)
  • Re: Problem with socket
    ... Be aware that those port numbers are part of the IANA-assigned range. ... socket operations on sockets for which there are no handles... ... The result of using comma lists is ... you have used the completely meaningless word "crash" to describe your ...
    (microsoft.public.vc.mfc)