Merge: Binary over network
authorJean Privat <jean@pryen.org>
Tue, 26 May 2015 10:12:35 +0000 (06:12 -0400)
committerJean Privat <jean@pryen.org>
Tue, 26 May 2015 12:38:00 +0000 (08:38 -0400)
Add services to write strings in binary streams and better support for binary in network modules.

Pull-Request: #1390
Reviewed-by: Alexandre Terrasa <alexandre@moz-code.org>
Reviewed-by: Jean Privat <jean@pryen.org>

1  2 
lib/socket/socket_c.nit

@@@ -134,12 -134,13 +134,13 @@@ extern class NativeSocket `{ int* `
  
        # Write `value` as a single byte
        fun write_byte(value: Int): Int `{
-               return write(*recv, &value, 1);
+               unsigned char byt = (unsigned char)value;
+               return write(*recv, &byt, 1);
        `}
  
 -      fun read: String import NativeString.to_s_with_length `{
 +      fun read: String import NativeString.to_s_with_length, NativeString.to_s_with_copy `{
                static char c[1024];
 -              int n = read(*recv, c, 1024);
 +              int n = read(*recv, c, 1023);
                if(n < 0) {
                        return NativeString_to_s_with_length("",0);
                }