Tutorial :How can I send a NULL in Ruby Sockets?



Question:

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.


Solution:1

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)


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »