Sockets
WriteBinary
write binary data on a socket connection
Calling Sequence
Parameters
Description
Examples
WriteBinary(sid, a)
sid
-
socket ID for the socket connection
a
rtable with hardware datatype
The procedure Sockets[Write] cannot be used to write binary data on a socket connection because Maple strings cannot encode the data. Therefore, the interface WriteBinary is provided to enable you to send binary data onto a socket connection.
The first argument is a valid and open socket ID sid on which the data is written. The second argument is an rtable a with a hardware datatype that contains the data you want to write to the socket connection.
The rtable a cannot use indexing functions and it must have rectangular storage. The rtable can have any of the following hardware datatypes:
integer[ 1 ]
integer[ 2 ]
integer[ 4 ]
integer[ 8 ]
float[ 4 ]
float[ 8 ]
If the datatype of a is anything but integer[1], then the data is treated as structured and each "record" is converted to Network Byte Order before being written to the socket.
The number of bytes actually written to the socket is returned as a Maple (non-negative) integer.
with⁡Sockets:
sid≔Open⁡mantis,echo
0
a≔Array⁡convert⁡Hello,bytes,datatype=integer1
a≔72101108108111
WriteBinary⁡sid,a
5
Read⁡sid
Hello
Close⁡sid
true
See Also
rtable
socket definition
Sockets[ReadBinary]
Sockets[Write]
Download Help Document