On socklisten

From Scriptwiki
Revision as of 20:32, 9 May 2008 by Aca20031 (talk | contribs) (Example)

Jump to: navigation, search

The on socklisten event triggers when a remote computer attempts to connect to a port on which mIRC is listening

on 1:socklisten:<name>:<commands>
  • The level is useless here, since no user is involved and therefore there is no user level.
  • The name is the name is the name provided in /socklisten
  • Commands are like any other event, a single command, or block of multiple commands, to perform on this event.

Listening

For mIRC to accept an incoming TCP connection, it must first be listening on the port that the connection attempt is made on. To listen, you must use the Socklisten command. The name you provide here is the name that will be used in the event.

Accepting

In order to start interacting with a remote computer, the socket must be accepted from the socklisten event. To do this, we use the Sockaccept command.

Filtering

Most of the time you do not want to allow every computer access to this socket, that could cause security risks. You may want to only allow certain IP addresses. To filter, you must first accept the socket and then check and see if you want to allow the remote computer further access to your script. If you do not, Sockclose the socket immediately.

Examples

on *:SOCKLISTEN:MyWebServer: {
 sockaccept Check
 if ($sock(check).ip == allowedIP) {
   Sockrename Check MyWebServerConnection $+ $ticks
 }
 else { sockclose Check }
}