mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Feb 2003
Posts: 2,737
R
Raccoon Offline OP
Hoopy frood
OP Offline
Hoopy frood
R
Joined: Feb 2003
Posts: 2,737
I've always wondered about this as it's not very well documented.

This problem exists for SockListen/SockRead events, when dealing with Listening Sockets and Connecting Clients. When initiating a connection with /SockOpen, these identifiers work just dandy, returning the expected information.

$sock().ip returns Client IP
$sock().port returns YOUR Listening Port
$sock().saddr is UDP _only_
$sock().sport is UDP _only_
$sock().bindip is bind IP specified in /socklisten
$sock().bindport is... hmm, can't specify a bindport yet.

As you can see, an identifier exists to return the Connector's IP address, but none exists to return their Port. This information is available in /socklist but not by identifier.
httpd.80.1145778659.80 192.168.0.42:[color:red]1696 tcp active (on: 192.168.0.42 80)[/color]

There is also an identifier to return your "bindport" (presumably useful if you're behind a router), but no command that allows you to set it.

I would like to recommend $sock().port returns the Client's port, and $sock().lport returns the server's Listening port.

- Raccoon

Edit:
I just noticed This Thread where someone suggests $sock().lport for the Local Port (client port). I still say .port should do that job, and .lport return the Listening Port. Another alternative would be to propogate .sport and .saddr for TCP connections aswell.

Joined: Dec 2002
Posts: 127
F
Vogon poet
Offline
Vogon poet
F
Joined: Dec 2002
Posts: 127
actually, i've had some problems with $sock().ip. almost invariably it doesn't immediately return anything, even though the socklisten/sockopen events have been triggered. but, once i have sent some data (i'm not sure how much, maybe it varies) to that socket, then mirc can return the right value from $sock().ip.


Link Copied to Clipboard