Socket write()
syntax: |
socket.write(source, description) |
where: |
source - Source variable to write to the socket
description - Variable description describing how to write the source variable to the socket.
|
return: |
number - the number of elements written.
|
description: |
This method is almost identical to Clib.fwrite(), except that it writes to the current socket, rather than to a supplied file. The description variable acts in the same way as in Clib.fwrite(). If it is a positive value, then source is treated as a buffer of the specified length. Otherwise, description must be a Blob value (SWORD8, UWORD32, etc) or a blobDescriptor object describing how the data should be written to the socket. If source is a buffer, then the number of bytes written is returned, otherwise 1 is returned if the datum is successfully written, -1 otherwise. Use Socket error() to determine the nature of the error.
|
see: |
#link <sesock>, Clib.fwrite(), Socket read(), Socket error()
|
example: |
function writeInfo( socket, info ) { if( !socket.write( info.name, 12 ) || !socket.write( info.age, UWORD8 ) || !socket.write( info.extension, UWORD16 ) ) return false; else return true; }
/* This function will write the contents * of the info object to the * specified socket in a native data format. */ |