lib/binary: intro read/write strings as blocks
[nit.git] / lib / socket / socket_c.nit
index 8758cdf..518fcb5 100644 (file)
@@ -132,6 +132,12 @@ extern class NativeSocket `{ int* `}
                return write(*recv, (char*)String_to_cstring(buffer), String_length(buffer));
        `}
 
+       # Write `value` as a single byte
+       fun write_byte(value: Int): Int `{
+               unsigned char byt = (unsigned char)value;
+               return write(*recv, &byt, 1);
+       `}
+
        fun read: String import NativeString.to_s_with_length `{
                static char c[1024];
                int n = read(*recv, c, 1024);