mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Mar 2007
Posts: 40
S
silimon Offline OP
Ameglian cow
OP Offline
Ameglian cow
S
Joined: Mar 2007
Posts: 40
Say you had a script with a looping(0-0) timer that constanty activates at no delay. Also within this script is a sockread event that's for a socket continually listening to data.

Say while you finish processing the part of the script tied to the sockread event, more information is dropped off at the socket. Is it possible for the sockread to read twice or more in a row without the timer activating at least once? I don't really have a good means to test this and this would effectively jam-up the script if someone was flooding the socket with information.

Joined: Aug 2004
Posts: 7,252
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
Since mIRC scripting is single threaded, I would think that the execution of a 0 second timer set at 0 (infinite) repetitions would lock up your script, and mIRC, since no other process could be started in the delay the timer runs at.

Thus said, if the sockread in your script was coded after the timer, then the socket would not be read.

On the other hand, if it was coded before the timer, it would be read once, but not afterwards.

I do not recommend using a (0-0) timer, and in fact, I can't think of any reason for having a timer running that quickly.

If you need a fast timer, then try a millisecond timer and set it for 5 milliseconds. In my opinion, you probably wouldn't notice any difference.

Joined: Nov 2006
Posts: 1,559
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
A 0 0-timer won't freeze mIRC or the script.
Code:
//.timerinfinite 0 0 noop | timerbla 1 3 echo -a bla $(|,0) .timer 1 1 timerinfinite off

I second the scepticism bout the need for that a timer though smile

@silimon: If you really need the infinite timer, can't you stop it on sockread and restart it after $sockbr turned $null, or having received a specific chunk of data / specific ammount of bytes, or the like?

Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Or drop the timer altogether and have an alias call the socket event... then on sockclose, run the alias to open the socket again. It will loop as fast as possible that way without any need for timers and guarantees you avoid issues with the socket already being open or not finished reading the data.

That said, I'm sure there is a better way of handling the script. It probably doesn't need that non-stop reading of the socket. Checking every few seconds is probably good enough.

Last edited by Riamus2; 12/03/10 01:41 PM.

Invision Support
#Invision on irc.irchighway.net

Link Copied to Clipboard