Pastie now auto-senses if line-wrap is a bad or good idea. Feedback?
## mark a section (Learn more)
def send(msg, flags, to = nil) bytes = msg.length buffer = MemoryPointer.new :char, bytes buffer.write_string msg bytes_sent = Socket::Foreign.send(descriptor, buffer, bytes, flags) p "Sent: #{bytes_sent}" p "Message: #{buffer.read_string}" Errno.handle 'send(2)' if bytes_sent < 0 buffer.free return bytes_sent end send("hello", 0) => "Sent: 5" "Message: hello\225\211\300+9\001"
This paste will be private.
From the Design Piracy series on my blog: