I was not sure if this was implemented already so I checked the help file and figured it was not:
A lport property for the sock identifier that returns the port used by a socket on the local machine, ie local port.
You mean $sock().bindport?
.bindport does the trick in sockopen context.
however, when used in sockaccept context, it returns the port the related socklisten listens on.
Well, that is correct, isn't it?
If you're listening on port 80 and you accept a connection coming to port 80 your local port would be 80.
once the connection had been sockaccept'ed, it uses another port in range 1k-64k to free port 80.
$sock().port returns the remote port, not the local port.
The local port remains the same as the one on which you were listening and accepted the connection, different connections only have different remote ips and/or ports (which are all different, because people connecting to you can use each of their ports for only one outgoing connection at a time)
Ack, I should spend more time on sockets