mIRC Homepage
Posted By: t0m sock lport property - 18/03/03 02:57 AM
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.
Posted By: Rich Re: sock lport property - 18/03/03 12:01 PM
You mean $sock().bindport?
Posted By: t0m Re: sock lport property - 18/03/03 05:08 PM
.bindport does the trick in sockopen context.
however, when used in sockaccept context, it returns the port the related socklisten listens on.
Posted By: Rich Re: sock lport property - 18/03/03 08:01 PM
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.
Posted By: t0m Re: sock lport property - 19/03/03 03:50 AM
once the connection had been sockaccept'ed, it uses another port in range 1k-64k to free port 80.
Posted By: Collective Re: sock lport property - 19/03/03 08:10 AM
$sock(name).port works for that...
Code:
on *:SOCKLISTEN:pokemons:{
  sockaccept pokemon
  echo -a $sock(pokemon).port
}
Posted By: Rich Re: sock lport property - 19/03/03 11:58 AM
$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)
Posted By: Collective Re: sock lport property - 19/03/03 11:59 AM
Ack, I should spend more time on sockets crazy
© mIRC Discussion Forums