As reguards to the whole buffer not sending imiately and you having to add a bunch of code and recode built in functions of mIRC to get the socket to do what you wanted, I did it by adding a single line to your code:

Code:
on *:SOCKLISTEN:TestSocket:{
 sockaccept test.s
 echo -s socket accepted
 sockwrite -tn test.s this is a test
}
on *:SOCKREAD:test*:{
 if ($sockerr > 0) { echo -s error on socket | sockclose $sockname }
 sockread -fn &Read.test | tokenize 32 $bvar(&Read.test,1,$bvar(&Read.test,0)).text
 echo -s $sockname received: $1-
 if ($1 == dotest) {
  sockwrite -tn $sockname testing 1
  sockwrite -tn $sockname testing 2
  sockwrite -tn $sockname testing 3
 }
}
on *:SOCKWRITE:test*:{
 echo -s $sockname sent data
 if (!$sock($sockname).sq) { echo -s $sockname Done sending data, closing socket! | sockclose $sockname }
}
on *:SOCKCLOSE:test*:{
 echo -s $sockname socket closed
}
on *:SOCKOPEN:test*:{
 echo -s $sockname socket opened
 if ($sockname == test) { sockwrite -tn test dotest }
}
alias testsocket {
 socklisten TestSocket 1010
 sockopen test localhost 1010
}
alias sockwrite {
 echo -s data sent to: $2 was: $3-
 sockwrite $1-
}


but if you wanted to be even more precise, you could check $sock().rq and $sock().secs before closing it....

Last edited by FroggieDaFrog; 19/02/11 05:24 AM.