You probably have an echo in your sockread event similar to this:
if ($sockerr) { echo -s socket error ( $+ $sockerr $+ ) }
It doesn't have to look exactly like that, but most likely, you'll find $sockerr somewhere in there. Look for that part of the script and replace it with something similar to:
if ($sockerr) { echo -s socket error ( $+ $sockerr $+ : $sock($sockname).wsmsg $+ ) }
That will give the message as well as the code. Again, it doesn't have to look that way... just include the $sock($sockname).wsmsg echo inside the IF in whatever format you want and you'll have your message.