Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I send a NULL in Ruby Sockets?

Tags:

null

ruby

sockets

I'm working on a socket app in Ruby Shoes, and want to send a message to the server. The server expects the XML message, and then a null (0) character.

How can I send that in TCP Sockets in Ruby?

Thanks.

like image 736
RyanE Avatar asked May 30 '26 19:05

RyanE


1 Answers

I found my own answer... The problem was not sending the NULL, it was a thread issue.

You can send a NULL as part of a string by just concatenating it on to the end of the string...

NULL = "\000"

... tc = tc + "</endtag>"

tc = tc + NULL

Socket.send(tc, 0)

like image 158
RyanE Avatar answered Jun 01 '26 18:06

RyanE