How to send byte array via TCP when using newLISP

156 Views Asked by At

I want to send two bytes which represent an unsigned short in big-endian to server via TCP. But net-send only supports string parameter. Could anyone tell me how to do this with newLISP?

1

There are 1 best solutions below

0
On

It works now. CODE: SELECT ALL

(set 'socket (net-connect "localhost" 8889)) 16 (set 'size (pack ">d" 19)) "\000\019" (net-send socket size) 2

pack returns a string buffer that contains my two bytes, net-send sends the string to server. My C++ server got two bytes, 0 and 19. Thanks.