How can I send NULL to Ruby Sockets?

I am working on a socket application in Ruby Shoes and want to send a message to the server. The server expects an XML message, followed by a null (0) character.

How can I send this to TCP sockets in Ruby?

Thanks.

+3
source share
1 answer

I found my own answer ... The problem is not sending NULL, this is a thread problem.

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

NULL = "\ 000"

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

tc = tc + NULL

Socket.send (tc, 0)

+4
source

Source: https://habr.com/ru/post/1702289/


All Articles