You should check $sock(name).sq to see how much data is queued to send before trying to sockwrite more.
Socket Identifiers

$sock(name,N)
This returns information about a socket connection that you created using the socket commands.

Properties: name, ip, port, status, sent, rcvd, sq, rq, ls, lr, mark, type, saddr, sport, to, wserr, wsmsg, bindip, bindport

.name is the name you give to a connection to identify it

.sent and .rcvd return the number of bytes sent and rcvd over that connection so far
.sq and .rq return the number of bytes queued in the send and receive buffers respectively