I'll try to clarify the issue. (I'm no socket expert though)

When the different events "On sockopen", "On sockwrite" and "On sockread" are triggered, any error that may have been received or sent can/must be detected at the top of the event directly without having to check for an error after each socket command. When you do /sockopen, "on sockopen" is triggered. When you do /sockwrite, "on sockwrite" is triggered (when all the data has been sent) and eventually, because of the /sockwrite, the remote application/server will produce a reply and that's when "on sockread" is triggered. Also, "on sockread" is triggered whenever you receive something remotely, whether you did a /sockwrite or not.

I mean by this that the "On sockopen" event should be coupled with a "On sockread" and/or with a "On sockwrite" event to be able to get the error (if any) when the remote server/application replies.

The "on sockopen" and "on sockwrite" only triggers when the client 'opens' and 'writes to' a socket and will produce only client errors. To be able to see the remote server's/application's errors (if any), you must use "on sockread" with the same "if $sockerr { return }" check on top.

Basically it should ressemble the following:
Code:
on *:sockopen:name:{
  if $sockerr { echo -st - $sockname error - $sock($sockname).wserr | return }
  commands
}
On *:sockread:name:{
  if $sockerr { echo -st - $sockname error - $sock($sockname).wserr | return }
  commands
}
on *:sockwrite:name:{
  if $sockerr { echo -st - $sockname error - $sock($sockname).wserr | return }
  commands
}

I don't know if I've been clear but I've tried to. :s

--
I'll add this to the explanation:

Even if an error occured for example as a consequence of the 7th /sockwrite in a 'on sockopen' event, the error would only be detected in the 'on sockwrite' event when all the contents of that /sockwrite have been sent!

Same when receiving data. Errors will be detected only when your mIRC actually receives the data, that is, when the 'on sockread' event is triggered.
--

Cordialement

Last edited by TropNul; 17/12/07 05:31 AM.

tropnul