@@ -32,44 +32,44 @@ var echo_server = net.createServer(function (socket) {
32
32
33
33
echo_server . listen ( common . PORT , function ( ) {
34
34
console . log ( "server listening at " + common . PORT ) ;
35
- } ) ;
36
35
37
- var client = net . createConnection ( common . PORT ) ;
38
- client . setEncoding ( "UTF8" ) ;
39
- client . setTimeout ( 0 ) ; // disable the timeout for client
40
- client . addListener ( "connect" , function ( ) {
41
- console . log ( "client connected." ) ;
42
- client . write ( "hello\r\n" ) ;
43
- } ) ;
36
+ var client = net . createConnection ( common . PORT ) ;
37
+ client . setEncoding ( "UTF8" ) ;
38
+ client . setTimeout ( 0 ) ; // disable the timeout for client
39
+ client . addListener ( "connect" , function ( ) {
40
+ console . log ( "client connected." ) ;
41
+ client . write ( "hello\r\n" ) ;
42
+ } ) ;
44
43
45
- client . addListener ( "data" , function ( chunk ) {
46
- assert . equal ( "hello\r\n" , chunk ) ;
47
- if ( exchanges ++ < 5 ) {
48
- setTimeout ( function ( ) {
49
- console . log ( "client write 'hello'" ) ;
50
- client . write ( "hello\r\n" ) ;
51
- } , 500 ) ;
52
-
53
- if ( exchanges == 5 ) {
54
- console . log ( "wait for timeout - should come in " + timeout + " ms" ) ;
55
- starttime = new Date ;
56
- console . dir ( starttime ) ;
44
+ client . addListener ( "data" , function ( chunk ) {
45
+ assert . equal ( "hello\r\n" , chunk ) ;
46
+ if ( exchanges ++ < 5 ) {
47
+ setTimeout ( function ( ) {
48
+ console . log ( "client write 'hello'" ) ;
49
+ client . write ( "hello\r\n" ) ;
50
+ } , 500 ) ;
51
+
52
+ if ( exchanges == 5 ) {
53
+ console . log ( "wait for timeout - should come in " + timeout + " ms" ) ;
54
+ starttime = new Date ;
55
+ console . dir ( starttime ) ;
56
+ }
57
57
}
58
- }
59
- } ) ;
58
+ } ) ;
60
59
61
- client . addListener ( "timeout" , function ( ) {
62
- throw new Error ( "client timeout - this shouldn't happen" ) ;
63
- } ) ;
60
+ client . addListener ( "timeout" , function ( ) {
61
+ throw new Error ( "client timeout - this shouldn't happen" ) ;
62
+ } ) ;
64
63
65
- client . addListener ( "end" , function ( ) {
66
- console . log ( "client end" ) ;
67
- client . end ( ) ;
68
- } ) ;
64
+ client . addListener ( "end" , function ( ) {
65
+ console . log ( "client end" ) ;
66
+ client . end ( ) ;
67
+ } ) ;
69
68
70
- client . addListener ( "close" , function ( ) {
71
- console . log ( "client disconnect" ) ;
72
- echo_server . close ( ) ;
69
+ client . addListener ( "close" , function ( ) {
70
+ console . log ( "client disconnect" ) ;
71
+ echo_server . close ( ) ;
72
+ } ) ;
73
73
} ) ;
74
74
75
75
process . addListener ( "exit" , function ( ) {
0 commit comments