File tree 2 files changed +48
-1
lines changed
2 files changed +48
-1
lines changed Original file line number Diff line number Diff line change @@ -437,7 +437,7 @@ Connection::OnReceive (const void *buf, size_t len)
437
437
// raw encoding
438
438
Local<Array> array = Array::New (len);
439
439
for (size_t i = 0 ; i < len; i++) {
440
- char val = static_cast <const char *>(buf)[i];
440
+ unsigned char val = static_cast <const unsigned char *>(buf)[i];
441
441
array->Set (Integer::New (i), Integer::New (val));
442
442
}
443
443
argv[0 ] = array;
Original file line number Diff line number Diff line change
1
+ include ( "mjsunit.js" ) ;
2
+ PORT = 23123 ;
3
+
4
+ var echoServer = node . tcp . createServer ( function ( connection ) {
5
+ connection . addListener ( "receive" , function ( chunk ) {
6
+ connection . send ( chunk , "raw" ) ;
7
+ } ) ;
8
+ connection . addListener ( "eof" , function ( ) {
9
+ connection . close ( ) ;
10
+ } ) ;
11
+ } ) ;
12
+ echoServer . listen ( PORT ) ;
13
+
14
+ var recv = [ ] ;
15
+ var j = 0 ;
16
+
17
+ function onLoad ( ) {
18
+ var c = node . tcp . createConnection ( PORT ) ;
19
+
20
+ c . addListener ( "receive" , function ( chunk ) {
21
+ if ( ++ j < 256 ) {
22
+ c . send ( [ j ] , "raw" ) ;
23
+ } else {
24
+ c . close ( ) ;
25
+ }
26
+ for ( var i = 0 ; i < chunk . length ; i ++ ) {
27
+ recv . push ( chunk [ i ] ) ;
28
+ }
29
+ } ) ;
30
+
31
+ c . addListener ( "connect" , function ( ) {
32
+ c . send ( [ j ] , "raw" ) ;
33
+ } ) ;
34
+
35
+ c . addListener ( "disconnect" , function ( ) {
36
+ p ( recv ) ;
37
+ echoServer . close ( ) ;
38
+ } ) ;
39
+ } ;
40
+
41
+ function onExit ( ) {
42
+ var expected = [ ] ;
43
+ for ( var i = 0 ; i < 256 ; i ++ ) {
44
+ expected . push ( i ) ;
45
+ }
46
+ assertEquals ( expected , recv ) ;
47
+ }
You can’t perform that action at this time.
0 commit comments