mIRC Home    About    Download    Register    News    Help

Print Thread
#15845 18/03/03 02:57 AM
Joined: Mar 2003
Posts: 16
T
t0m Offline OP
Pikka bird
OP Offline
Pikka bird
T
Joined: Mar 2003
Posts: 16
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.

#15846 18/03/03 12:01 PM
Joined: Dec 2002
Posts: 117
R
Vogon poet
Offline
Vogon poet
R
Joined: Dec 2002
Posts: 117
You mean $sock().bindport?


$input(Me like stars, You too?)
#15847 18/03/03 05:08 PM
Joined: Mar 2003
Posts: 16
T
t0m Offline OP
Pikka bird
OP Offline
Pikka bird
T
Joined: Mar 2003
Posts: 16
.bindport does the trick in sockopen context.
however, when used in sockaccept context, it returns the port the related socklisten listens on.

#15848 18/03/03 08:01 PM
Joined: Dec 2002
Posts: 117
R
Vogon poet
Offline
Vogon poet
R
Joined: Dec 2002
Posts: 117
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.


$input(Me like stars, You too?)
#15849 19/03/03 03:50 AM
Joined: Mar 2003
Posts: 16
T
t0m Offline OP
Pikka bird
OP Offline
Pikka bird
T
Joined: Mar 2003
Posts: 16
once the connection had been sockaccept'ed, it uses another port in range 1k-64k to free port 80.

#15850 19/03/03 08:10 AM
Joined: Dec 2002
Posts: 3,138
C
Hoopy frood
Offline
Hoopy frood
C
Joined: Dec 2002
Posts: 3,138
$sock(name).port works for that...
Code:
on *:SOCKLISTEN:pokemons:{
  sockaccept pokemon
  echo -a $sock(pokemon).port
}

#15851 19/03/03 11:58 AM
Joined: Dec 2002
Posts: 117
R
Vogon poet
Offline
Vogon poet
R
Joined: Dec 2002
Posts: 117
$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)


$input(Me like stars, You too?)
#15852 19/03/03 11:59 AM
Joined: Dec 2002
Posts: 3,138
C
Hoopy frood
Offline
Hoopy frood
C
Joined: Dec 2002
Posts: 3,138
Ack, I should spend more time on sockets crazy


Link Copied to Clipboard