1

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?

Dean Chen
  • 3,800
  • 8
  • 45
  • 70

1 Answers1

2

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.

Dean Chen
  • 3,800
  • 8
  • 45
  • 70