mIRC Home    About    Download    Register    News    Help

Print Thread
#27084 30/05/03 07:45 PM
Joined: May 2003
Posts: 730
S
ScatMan Offline OP
Hoopy frood
OP Offline
Hoopy frood
S
Joined: May 2003
Posts: 730
i have two mircs open, in the first one i put this:
on *:socklisten:dg:{ sockaccept dg1 | sockclose dg }
on *:sockread:dg1:{
while ($sock(dg1).rq) {
sockread &var
bwrite f.txt -1 &var
}
}
and in the second i put this:
on *:sockopen:dg:{
if ($sockerr) halt
var %a = 0,%b = 8192
while (%b <= $file(versions.txt).size) {
bread versions.txt %a %b &f
sockwrite dg &f
inc %a 8192 | inc %b 8192
}
sockwrite dg &f
sockclose dg
}
so the script should listen in the first mirc (/socklisten dg 78) and connect from the second (//sockopen dg $ip 78), after it connects it sends a file from the second mirc to the first mirc
the problem is that it doesn't send the whole file, the size of versions.txt is 42740 bytes and what i get to f.txt is only 32768 bytes
what's the problem??


#27085 31/05/03 08:14 AM
Joined: Dec 2002
Posts: 103
Vogon poet
Offline
Vogon poet
Joined: Dec 2002
Posts: 103
You can't send the entire file at once, it'll exceed a queue limit. You need to use the on SOCKWRITE event to detect when you can send another lot of data.

try http://helpdesk.zaz.net/documents/socks.php (assuming it still exists...)

#27086 31/05/03 11:04 AM
Joined: May 2003
Posts: 730
S
ScatMan Offline OP
Hoopy frood
OP Offline
Hoopy frood
S
Joined: May 2003
Posts: 730
that's why i used loop that will send 8192 each time and it CAN be done becuz 8192 is the maximum bytes u can send at once, the problem is that the 1KB from the end of versions.txt didn't send, i dunno why
any ideas??

#27087 31/05/03 11:45 AM
Joined: Dec 2002
Posts: 2,962
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 2,962
while (%b <= $file(versions.txt).size) {
bread versions.txt %a %b &f
sockwrite dg &f
inc %a 8192 | inc %b 8192
}


%b shouldn't exist, it should simply be a static 8192 in the /bread line and you should be comparing %a in the while condition.

while (%a <= $file(versions.txt).size) {
bread versions.txt %a 8192 &f
sockwrite dg &f
inc %a 8192
}


Spelling mistakes, grammatical errors, and stupid comments are intentional.
#27088 31/05/03 12:52 PM
Joined: May 2003
Posts: 730
S
ScatMan Offline OP
Hoopy frood
OP Offline
Hoopy frood
S
Joined: May 2003
Posts: 730
still, doesn't working smirk it sends the same data like before smirk not the whole file


#27089 31/05/03 03:26 PM
Joined: Dec 2002
Posts: 5,426
Hoopy frood
Offline
Hoopy frood
Joined: Dec 2002
Posts: 5,426
When you use /sockwrite you are in effect queuing data to be sent on that socket.

Once the queued data has been sent, mIRC will trigger the on sockwrite event to indicate that you can now send more data.

Remember to check for $sockerr in the first line of the event though to check if an error has occurred.

#27090 31/05/03 04:38 PM
Joined: May 2003
Posts: 79
A
Babel fish
Offline
Babel fish
A
Joined: May 2003
Posts: 79
Just like Khaled said before, once the data are send, you have an on sockwrite event. You can only queue 8192 bytes in the buffer to be sent, so with your while, you are reading 8192 bytes at each bread, but you are trying to queue all the file at the sametime. When you have an on sockwrite event, you queue 8192 bytes, another on sockwrite means the queue is empty, so you can queue another 8192 bytes ... and on. I hope you will understand how it works.
And you don't have to queue 8192 bytes, you can queue less that this if you want, 8192 is only the maximum.

#27091 31/05/03 06:07 PM
Joined: May 2003
Posts: 730
S
ScatMan Offline OP
Hoopy frood
OP Offline
Hoopy frood
S
Joined: May 2003
Posts: 730
it works great!!!!!!!! laugh
on *:sockopen:dg:{
if ($sockerr) halt
%a = 0
bread versions.txt %a 8192 &f
sockwrite dg &f
}
on *:sockwrite:dg:{
if (!$sockerr) {
if (%a <= $file(versions.txt)) {
inc %a 8192
bread versions.txt %a 8192 &f
sockwrite dg &f
}
else { sockclose dg }
}
}
thanks alot Khaled & Artwerks


Link Copied to Clipboard