@@ -29,46 +29,46 @@ let starttime = null;
29
29
let timeouttime = null ;
30
30
const timeout = 1000 ;
31
31
32
- const echo_server = net . createServer ( function ( socket ) {
32
+ const echo_server = net . createServer ( ( socket ) => {
33
33
socket . setTimeout ( timeout ) ;
34
34
35
- socket . on ( 'timeout' , function ( ) {
35
+ socket . on ( 'timeout' , ( ) => {
36
36
console . log ( 'server timeout' ) ;
37
37
timeouttime = new Date ( ) ;
38
38
console . dir ( timeouttime ) ;
39
39
socket . destroy ( ) ;
40
40
} ) ;
41
41
42
- socket . on ( 'error' , function ( e ) {
42
+ socket . on ( 'error' , ( e ) => {
43
43
throw new Error (
44
44
'Server side socket should not get error. We disconnect willingly.' ) ;
45
45
} ) ;
46
46
47
- socket . on ( 'data' , function ( d ) {
47
+ socket . on ( 'data' , ( d ) => {
48
48
console . log ( d ) ;
49
49
socket . write ( d ) ;
50
50
} ) ;
51
51
52
- socket . on ( 'end' , function ( ) {
52
+ socket . on ( 'end' , ( ) => {
53
53
socket . end ( ) ;
54
54
} ) ;
55
55
} ) ;
56
56
57
- echo_server . listen ( common . PORT , function ( ) {
57
+ echo_server . listen ( common . PORT , ( ) => {
58
58
console . log ( `server listening at ${ common . PORT } ` ) ;
59
59
60
60
const client = net . createConnection ( common . PORT ) ;
61
61
client . setEncoding ( 'UTF8' ) ;
62
62
client . setTimeout ( 0 ) ; // disable the timeout for client
63
- client . on ( 'connect' , function ( ) {
63
+ client . on ( 'connect' , ( ) => {
64
64
console . log ( 'client connected.' ) ;
65
65
client . write ( 'hello\r\n' ) ;
66
66
} ) ;
67
67
68
- client . on ( 'data' , function ( chunk ) {
68
+ client . on ( 'data' , ( chunk ) => {
69
69
assert . strictEqual ( chunk , 'hello\r\n' ) ;
70
70
if ( exchanges ++ < 5 ) {
71
- setTimeout ( function ( ) {
71
+ setTimeout ( ( ) => {
72
72
console . log ( 'client write "hello"' ) ;
73
73
client . write ( 'hello\r\n' ) ;
74
74
} , 500 ) ;
@@ -81,22 +81,22 @@ echo_server.listen(common.PORT, function() {
81
81
}
82
82
} ) ;
83
83
84
- client . on ( 'timeout' , function ( ) {
84
+ client . on ( 'timeout' , ( ) => {
85
85
throw new Error ( "client timeout - this shouldn't happen" ) ;
86
86
} ) ;
87
87
88
- client . on ( 'end' , function ( ) {
88
+ client . on ( 'end' , ( ) => {
89
89
console . log ( 'client end' ) ;
90
90
client . end ( ) ;
91
91
} ) ;
92
92
93
- client . on ( 'close' , function ( ) {
93
+ client . on ( 'close' , ( ) => {
94
94
console . log ( 'client disconnect' ) ;
95
95
echo_server . close ( ) ;
96
96
} ) ;
97
97
} ) ;
98
98
99
- process . on ( 'exit' , function ( ) {
99
+ process . on ( 'exit' , ( ) => {
100
100
assert . ok ( starttime != null ) ;
101
101
assert . ok ( timeouttime != null ) ;
102
102
0 commit comments