• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (C) 2024 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15import { describe, it, expect } from '@ohos/hypium';
16import socket from "@ohos.net.socket";
17import { BusinessError, Callback } from '@ohos.base';
18import { ArrayBufferToString } from './utils/index';
19
20function expectSuccess(): void {
21  expect(true).assertTrue();
22}
23
24function sleep(ms: number) {
25    return new Promise<void>(resolve => setTimeout(resolve, ms));
26}
27
28function expectFail(info: string = ''): void {
29  try {
30    expect(false).assertTrue();
31  } catch (err) {
32    console.info(`${info} test failed`);
33  }
34};
35
36
37function expectTrue(exp: boolean, info: string = ''): void {
38  try {
39    expect(exp).assertTrue();
40  } catch (err) {
41    console.info(`${info} test failed`);
42  }
43};
44
45function expectFalse(exp: boolean, info: string = ''): void {
46  try {
47    expect(exp).assertFalse();
48  } catch (err) {
49    console.info(`${info} test failed`);
50  }
51};
52
53function expectEqual(exp: string | number | boolean, assert: string | number | boolean, info: string = ''): void {
54  try {
55    console.info('JSON.stringify(exp),JSON.stringify(assert)' + JSON.stringify(exp), JSON.stringify(assert))
56    expect(exp).assertEqual(assert);
57  } catch (err) {
58    console.info(`${info} test failed`);
59  }
60};
61
62export default function TCPSocketTest() {
63  describe('ActsTCPSocketTest', () => {
64
65    /* *
66     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_ConstructTCPSocketInstance_0100
67     * @tc.name  : testNetworkMgrSocketTCPSocketConstructTCPSocketInstance0100
68     * @tc.desc  : Create a TCP Socket object
69     * @tc.size  : MediumTest
70     * @tc.type  : Function
71     * @tc.level : level 2
72     */
73    it('testNetworkMgrSocketTCPSocketConstructTCPSocketInstance0100', 0, async (done: Function) => {
74      let caseName: string = 'testNetworkMgrSocketTCPSocketConstructTCPSocketInstance0100';
75      console.info(`${caseName} test start `);
76      try {
77        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
78        console.info(`${caseName} success`);
79        expect(tcp).assertInstanceOf('Object');
80        done();
81      } catch (err) {
82        console.info(`${caseName}_catch fail err:${JSON.stringify(err)}`);
83        expectFail();
84        console.info(`${caseName} test end `);
85        done();
86      }
87    });
88
89    /* *
90     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_Bind_0100
91     * @tc.name  : testNetworkMgrSocketTCPSocketBind0100
92     * @tc.desc  : Bind IP address and port,Only fill in IPV4 address;  callback
93     * @tc.size  :  MediumTest
94     * @tc.type  : Function
95     * @tc.level : level 1
96     */
97    it('testNetworkMgrSocketTCPSocketBind0100', 0, async (done: Function) => {
98      let caseName: string = 'testNetworkMgrSocketTCPSocketBind0100';
99      try {
100        console.info(`${caseName} test start `);
101        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
102        expect(tcp).assertInstanceOf('Object');
103        let bindAddress: socket.NetAddress = {
104          address: '127.0.0.1'
105        };
106        tcp.bind(bindAddress, async (err: BusinessError) => {
107          if (err) {
108            console.info(`${caseName} fail err:${JSON.stringify(err)}`);
109            expectFail();
110          } else {
111            console.info(`${caseName} success`);
112            expectSuccess();
113          }
114          await tcp.close();
115          console.info(`${caseName} test end `);
116          done();
117        });
118      } catch (err) {
119        console.info(`${caseName}_catch fail err:${JSON.stringify(err)}`);
120        expectFail();
121        console.info(`${caseName} test end`);
122        done();
123      }
124    });
125
126    /* *
127     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_Bind_0300
128     * @tc.name  : testNetworkMgrSocketTCPSocketBind0300
129     * @tc.desc  : Bind IP address and port,the address and protocol are both IPV6;  callback
130     * @tc.size  :  MediumTest
131     * @tc.type  : Function
132     * @tc.level : level 1
133     */
134    it('testNetworkMgrSocketTCPSocketBind0300', 0, async (done: Function) => {
135      let caseName: string = 'testNetworkMgrSocketTCPSocketBind0300';
136      try {
137        console.info(`${caseName} test start `);
138        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
139        expect(tcp).assertInstanceOf('Object');
140        let bindAddress: socket.NetAddress = {
141          address: 'fe80::b3b:ecb5:77f:88dc%12',
142          family:2
143        };
144        tcp.bind(bindAddress, async (err: BusinessError) => {
145          if (err) {
146            console.info(`${caseName} fail err:${JSON.stringify(err)}`);
147            expectTrue(err.code===2301022);
148          } else {
149            console.info(`${caseName} success`);
150            expectFail();
151          }
152          await tcp.close();
153          console.info(`${caseName} test end `);
154          done();
155        });
156      } catch (err) {
157        console.info(`${caseName}_catch fail err:${JSON.stringify(err)}`);
158        expectFail();
159        console.info(`${caseName} test end`);
160        done();
161      }
162    });
163
164    /* *
165     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_Bind_0500
166     * @tc.name  : testNetworkMgrSocketTCPSocketBind0500
167     * @tc.desc  : Bind IP address and port,bad address;  callback
168     * @tc.size  :  MediumTest
169     * @tc.type  : Function
170     * @tc.level : level 2
171     */
172    it('testNetworkMgrSocketTCPSocketBind0500', 0, async (done: Function) => {
173      let caseName: string = 'testNetworkMgrSocketTCPSocketBind0500';
174      try {
175        console.info(`${caseName} test start `);
176        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
177        expect(tcp).assertInstanceOf('Object');
178        let bindAddress: socket.NetAddress = {
179          address: '100.0.0.0',
180          port: 4444,
181          family: 1
182        };
183        tcp.bind(bindAddress, async (err: BusinessError) => {
184          if (err) {
185            console.info(`${caseName} fail err:${JSON.stringify(err)}`);
186            expectEqual(err.code, 2301099);
187          } else {
188            console.info(`${caseName} success`);
189            expectFail();
190          }
191          await tcp.close();
192          console.info(`${caseName} test end `);
193          done();
194        });
195      } catch (err) {
196        console.info(`${caseName}_catch fail err:${JSON.stringify(err)}`);
197        expectFail();
198        console.info(`${caseName} test end `);
199        done();
200      }
201    });
202
203    /* *
204     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_Bind_0600
205     * @tc.name  : testNetworkMgrSocketTCPSocketBind0600
206     * @tc.desc  : Bind IP address and port,Port is boundary -1;  callback
207     * @tc.size  :  MediumTest
208     * @tc.type  : Function
209     * @tc.level : level 2
210     */
211    it('testNetworkMgrSocketTCPSocketBind0600', 0, async (done: Function) => {
212      let caseName: string = 'testNetworkMgrSocketTCPSocketBind0600';
213      try {
214        console.info(`${caseName} test start `);
215        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
216        expect(tcp).assertInstanceOf('Object');
217        let bindAddress: socket.NetAddress = {
218          address: '127.0.0.1',
219          port: -1,
220          family: 1
221        };
222        tcp.bind(bindAddress, async (err: BusinessError) => {
223          if (err) {
224            console.info(`${caseName} fail err:${JSON.stringify(err)}`);
225            expectFail();
226          } else {
227            console.info(`${caseName} success`);
228            expectSuccess();
229          }
230          await tcp.close();
231          console.info(`${caseName} test end`);
232          done();
233        });
234      } catch (err) {
235        console.info(`${caseName}_catch fail err:${JSON.stringify(err)}`);
236        expectFail();
237        console.info(`${caseName} test end`);
238        done();
239      }
240    });
241
242    /* *
243     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_Bind_0700
244     * @tc.name  : testNetworkMgrSocketTCPSocketBind0700
245     * @tc.desc  : Bind IP address and port,port is boundary 0;  callback
246     * @tc.size  :  MediumTest
247     * @tc.type  : Function
248     * @tc.level : level 2
249     */
250    it('testNetworkMgrSocketTCPSocketBind0700', 0, async (done: Function) => {
251      let caseName: string = 'testNetworkMgrSocketTCPSocketBind0700';
252      try {
253        console.info(`${caseName} test start `);
254        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
255        expect(tcp).assertInstanceOf('Object');
256        let bindAddress: socket.NetAddress = {
257          address: '127.0.0.1',
258          port: 0,
259          family: 1
260        };
261        tcp.bind(bindAddress, async (err: BusinessError) => {
262          if (err) {
263            console.info(`${caseName} fail err:${JSON.stringify(err)}`);
264            expectFail();
265          } else {
266            console.info(`${caseName} success`);
267            expectSuccess();
268          }
269          await tcp.close();
270          console.info(`${caseName} test end`);
271          done();
272        });
273      } catch (err) {
274        console.info(`${caseName}_catch fail err:${JSON.stringify(err)}`);
275        expectFail();
276        console.info(`${caseName} test end`);
277        done();
278      }
279    });
280
281    /* *
282     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_Bind_0800
283     * @tc.name  : testNetworkMgrSocketTCPSocketBind0800
284     * @tc.desc  : Bind IP address and port,Port is boundary 65535;  callback
285     * @tc.size  :  MediumTest
286     * @tc.type  : Function
287     * @tc.level : level 2
288     */
289    it('testNetworkMgrSocketTCPSocketBind0800', 0, async (done: Function) => {
290      let caseName: string = 'testNetworkMgrSocketTCPSocketBind0800';
291      try {
292        console.info(`${caseName} test start `);
293        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
294        expect(tcp).assertInstanceOf('Object');
295        let bindAddress: socket.NetAddress = {
296          address: '127.0.0.1',
297          port: 65535,
298          family: 1
299        };
300        tcp.bind(bindAddress, async (err: BusinessError) => {
301          if (err) {
302            console.info(`${caseName} fail err:${JSON.stringify(err)}`);
303            expectFail();
304          } else {
305            console.info(`${caseName} success`);
306            expectSuccess();
307          }
308          await tcp.close();
309          console.info(`${caseName} test end`);
310          done();
311        });
312      } catch (err) {
313        console.info(`${caseName}_catch fail err:${JSON.stringify(err)}`);
314        expectFail();
315        console.info(`${caseName} test end`);
316        done();
317      }
318    });
319
320    /* *
321     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_Bind_0900
322     * @tc.name  : testNetworkMgrSocketTCPSocketBind0900
323     * @tc.desc  : Bind IP address and port,Port is boundary 65536;  callback
324     * @tc.size  :  MediumTest
325     * @tc.type  : Function
326     * @tc.level : level 2
327     */
328    it('testNetworkMgrSocketTCPSocketBind0900', 0, async (done: Function) => {
329      let caseName: string = 'testNetworkMgrSocketTCPSocketBind0900';
330      try {
331        console.info(`${caseName} test start `);
332        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
333        expect(tcp).assertInstanceOf('Object');
334        let bindAddress: socket.NetAddress = {
335          address: '127.0.0.1',
336          port: 65536,
337          family: 1
338        };
339        tcp.bind(bindAddress, async (err: BusinessError) => {
340          if (err) {
341            console.info(`${caseName} fail err:${JSON.stringify(err)}`);
342            expectFail();
343          } else {
344            console.info(`${caseName} success`);
345            expectSuccess();
346          }
347          await tcp.close();
348          console.info(`${caseName} test end`);
349          done();
350        });
351      } catch (err) {
352        console.info(`${caseName}_catch fail err:${JSON.stringify(err)}`);
353        expectFail();
354        console.info(`${caseName} test end`);
355        done();
356      }
357    });
358
359    /* *
360     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_Bind_1000
361     * @tc.name  : testNetworkMgrSocketTCPSocketBind1000
362     * @tc.desc  : Bind IP address and port, bad family;  callback
363     * @tc.size  :  MediumTest
364     * @tc.type  : Function
365     * @tc.level : level 2
366     */
367    it('testNetworkMgrSocketTCPSocketBind1000', 0, async (done: Function) => {
368      let caseName: string = 'testNetworkMgrSocketTCPSocketBind1000';
369      try {
370        console.info(`${caseName} test start `);
371        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
372        expect(tcp).assertInstanceOf('Object');
373        let bindAddress: socket.NetAddress = {
374          address: '127.0.0.1',
375          port: 4554,
376          family: 3
377        };
378        tcp.bind(bindAddress, async (err: BusinessError) => {
379          if (err) {
380            console.info(`${caseName} fail err:${JSON.stringify(err)}`);
381            expectFail();
382          } else {
383            console.info(`${caseName} success`);
384            expectSuccess();
385          }
386          await tcp.close();
387          console.info(`${caseName} test end `);
388          done();
389        });
390      } catch (err) {
391        console.info(`${caseName}_catch fail err:${JSON.stringify(err)}`);
392        expectFail();
393        console.info(`${caseName} test end `);
394        done();
395      }
396    });
397
398    /* *
399     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_Bind_1100
400     * @tc.name  : testNetworkMgrSocketTCPSocketBind1100
401     * @tc.desc  : Bind IP address and port,Input parameter is null;  callback
402     * @tc.size  :  MediumTest
403     * @tc.type  : Function
404     * @tc.level : level 2
405     */
406    it('testNetworkMgrSocketTCPSocketBind1100', 0, async (done: Function) => {
407      let caseName: string = 'testNetworkMgrSocketTCPSocketBind1100';
408      try {
409        console.info(`${caseName} test start `);
410        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
411        expect(tcp).assertInstanceOf('Object');
412        tcp.bind(null, (err: BusinessError) => {
413          if (err) {
414            console.info(`${caseName} fail err:${JSON.stringify(err)}`);
415            expect(err.code).assertEqual(401);
416          } else {
417            console.info(`${caseName} success`);
418            expectFail();
419          }
420          console.info(`${caseName} test end `);
421          done();
422        });
423      } catch (err) {
424        console.info(`${caseName}_catch fail err:${JSON.stringify(err)}`);
425        expectFail();
426        console.info(`${caseName} test end `);
427        done();
428      }
429    });
430
431    /* *
432     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_Bind_1200
433     * @tc.name  : testNetworkMgrSocketTCPSocketBind1200
434     * @tc.desc  : Bind IP address and port,Input parameter is undefined;  callback
435     * @tc.size  :  MediumTest
436     * @tc.type  : Function
437     * @tc.level : level 2
438     */
439    it('testNetworkMgrSocketTCPSocketBind1200', 0, async (done: Function) => {
440      let caseName: string = 'testNetworkMgrSocketTCPSocketBind1200';
441      try {
442        console.info(`${caseName} test start `);
443        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
444        expect(tcp).assertInstanceOf('Object');
445        tcp.bind(undefined, (err: BusinessError) => {
446          if (err) {
447            console.info(`${caseName} fail err:${JSON.stringify(err)}`);
448            expect(err.code).assertEqual(401);
449          } else {
450            console.info(`${caseName} success`);
451            expectFail();
452          }
453          console.info(`${caseName} test end `);
454          done();
455        });
456      } catch (err) {
457        console.info(`${caseName}_catch fail err:${JSON.stringify(err)}`);
458        expectFail();
459        console.info(`${caseName} test end `);
460        done();
461      }
462    });
463
464    /* *
465     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_Bind_1300
466     * @tc.name  : testNetworkMgrSocketTCPSocketBind1300
467     * @tc.desc  : Bind IP address and port,Only fill in IPV4 address; promise
468     * @tc.size  : MediumTest
469     * @tc.type  : Function
470     * @tc.level : level 2
471     */
472    it('testNetworkMgrSocketTCPSocketBind1300', 0, async (done: Function) => {
473      let caseName: string = 'testNetworkMgrSocketTCPSocketBind1300';
474      try {
475        console.info(`${caseName} test start `);
476        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
477        expect(tcp).assertInstanceOf('Object');
478        let bindAddress: socket.NetAddress = {
479          address: '127.0.0.1'
480        };
481        tcp.bind(bindAddress).then(() => {
482          console.info(`${caseName} success`);
483          expectSuccess();
484          done();
485        }).catch((err: BusinessError) => {
486          console.info(`${caseName} fail err:${JSON.stringify(err)}`);
487          expectFail();
488          done();
489        }).finally(async () => {
490          await tcp.close();
491          console.info(`${caseName} test end `);
492          done();
493        });
494      } catch (err) {
495        console.info(`${caseName}_catch fail err:${JSON.stringify(err)}`);
496        expectFail();
497        console.info(`${caseName} test end `);
498        done();
499      }
500    });
501
502    /* *
503     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_Bind_1400
504     * @tc.name  : testNetworkMgrSocketTCPSocketBind1400
505     * @tc.desc  : Bind IP address and port,Only fill in IPV6 address; promise
506     * @tc.size  : MediumTest
507     * @tc.type  : Function
508     * @tc.level : level 2
509     */
510    it('testNetworkMgrSocketTCPSocketBind1400', 0, async (done: Function) => {
511      let caseName: string = 'testNetworkMgrSocketTCPSocketBind1400';
512      try {
513        console.info(`${caseName} test start `);
514        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
515        expect(tcp).assertInstanceOf('Object');
516        let bindAddress: socket.NetAddress = {
517          address: 'fe80::b3b:ecb5:77f:88dc%12'
518        };
519        tcp.bind(bindAddress).then(() => {
520          console.info(`${caseName} success`);
521          expectFail();
522          done();
523        }).catch((err: BusinessError) => {
524          console.info(`${caseName} fail err:${JSON.stringify(err)}`);
525          expectSuccess();
526          done();
527        }).finally(async () => {
528          await tcp.close();
529          console.info(`${caseName} test end `);
530          done();
531        });
532      } catch (err) {
533        console.info(`${caseName}_catch fail err:${JSON.stringify(err)}`);
534        expectFail();
535        console.info(`${caseName} test end `);
536        done();
537      }
538    });
539
540    /* *
541     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_Bind_1500
542     * @tc.name  : testNetworkMgrSocketTCPSocketBind1500
543     * @tc.desc  : Bind IP address and port,The address and protocol are both IPV6; promise
544     * @tc.size  : MediumTest
545     * @tc.type  : Function
546     * @tc.level : level 2
547     */
548    it('testNetworkMgrSocketTCPSocketBind1500', 0, async (done: Function) => {
549      let caseName: string = 'testNetworkMgrSocketTCPSocketBind1500';
550      try {
551        console.info(`${caseName} test start `);
552        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
553        expect(tcp).assertInstanceOf('Object');
554        let bindAddress: socket.NetAddress = {
555          address: 'fe80::b3b:ecb5:77f:88dc%12',
556          family:2
557        };
558        tcp.bind(bindAddress).then(() => {
559          console.info(`${caseName} success`);
560          expectFail();
561          done();
562        }).catch((err: BusinessError) => {
563          console.info(`${caseName} fail err:${JSON.stringify(err)}`);
564          expectTrue(err.code===2301022);
565          done();
566        }).finally(async () => {
567          await tcp.close();
568          console.info(`${caseName} test end `);
569          done();
570        });
571      } catch (err) {
572        console.info(`${caseName}_catch fail err:${JSON.stringify(err)}`);
573        expectFail();
574        console.info(`${caseName} test end `);
575        done();
576      }
577    });
578
579    /* *
580     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_Bind_1600
581     * @tc.name  : testNetworkMgrSocketTCPSocketBind1600
582     * @tc.desc  : Bind IP address and port,Address and protocol inversion; promise
583     * @tc.size  : MediumTest
584     * @tc.type  : Function
585     * @tc.level : level 2
586     */
587    it('testNetworkMgrSocketTCPSocketBind1600', 0, async (done: Function) => {
588      let caseName: string = 'testNetworkMgrSocketTCPSocketBind1600';
589      try {
590        console.info(`${caseName} test start `);
591        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
592        expect(tcp).assertInstanceOf('Object');
593        let bindAddress: socket.NetAddress = {
594          address: '127.0.0.1',
595          port: 7458,
596          family: 2
597        };
598        tcp.bind(bindAddress).then(() => {
599          expectFail();
600          done();
601        }).catch((err: BusinessError) => {
602          console.info(`${caseName} fail ${JSON.stringify(err)}`);
603          expectTrue(err.code===401);
604          done();
605        }).finally(() => {
606          console.info(`${caseName} test end`);
607          done();
608        });
609      } catch (err) {
610        console.info(`${caseName}_catch fail ${JSON.stringify(err)}`);
611        expectFail();
612        console.info(`${caseName} test end`);
613        done();
614      }
615    });
616
617    /* *
618     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_Bind_1700
619     * @tc.name  : testNetworkMgrSocketTCPSocketBind1700
620     * @tc.desc  : Bind IP address and port, bad address; promise
621     * @tc.size  : MediumTest
622     * @tc.type  : Function
623     * @tc.level : level 2
624     */
625    it('testNetworkMgrSocketTCPSocketBind1700', 0, async (done: Function) => {
626      let caseName: string = 'testNetworkMgrSocketTCPSocketBind1700';
627      try {
628        console.info(`${caseName} test start`);
629        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
630        expect(tcp).assertInstanceOf('Object');
631        let bindAddress: socket.NetAddress = {
632          address: '100.0.0.1',
633          port: 7586,
634          family: 1
635        };
636        tcp.bind(bindAddress).then(() => {
637          console.info(`${caseName} success`);
638          expectFail();
639          done();
640        }).catch((err: BusinessError) => {
641          console.info(`${caseName} fail err:${JSON.stringify(err)}`);
642          expectEqual(err.code, 2301099);
643          done();
644        }).finally(() => {
645          console.info(`${caseName} test end `);
646          done();
647        });
648      } catch (err) {
649        console.info(`${caseName}_catch fail err:${JSON.stringify(err)}`);
650        expectFail();
651        console.info(`${caseName} test end `);
652        done();
653      }
654    });
655
656    /* *
657     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_Bind_1800
658     * @tc.name  : testNetworkMgrSocketTCPSocketBind1800
659     * @tc.desc  : Bind IP address and port,Port number is -1; promise
660     * @tc.size  : MediumTest
661     * @tc.type  : Function
662     * @tc.level : level 2
663     */
664    it('testNetworkMgrSocketTCPSocketBind1800', 0, async (done: Function) => {
665      let caseName: string = 'testNetworkMgrSocketTCPSocketBind1800';
666      try {
667        console.info(`${caseName} test start `);
668        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
669        expect(tcp).assertInstanceOf('Object');
670        let bindAddress: socket.NetAddress = {
671          address: '127.0.0.1',
672          port: -1,
673          family: 1
674        };
675        tcp.bind(bindAddress).then(() => {
676          console.info(`${caseName} success`);
677          expectSuccess();
678          done();
679        }).catch((err: BusinessError) => {
680          console.info(`${caseName} fail ${JSON.stringify(err)}`);
681          expectFail();
682          done();
683        }).finally(async () => {
684          await tcp.close();
685          console.info(`${caseName} test end `);
686          done();
687        });
688      } catch (err) {
689        console.info(`${caseName}_catch fail ${JSON.stringify(err)}`);
690        expectFail();
691        console.info(`${caseName} test end `);
692        done();
693      }
694    });
695
696    /* *
697     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_Bind_1900
698     * @tc.name  : testNetworkMgrSocketTCPSocketBind1900
699     * @tc.desc  : Bind IP address and port,Port number is 0; promise
700     * @tc.size  : MediumTest
701     * @tc.type  : Function
702     * @tc.level : level 2
703     */
704    it('testNetworkMgrSocketTCPSocketBind1900', 0, async (done: Function) => {
705      let caseName: string = 'testNetworkMgrSocketTCPSocketBind1900';
706      try {
707        console.info(`${caseName} test start `);
708        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
709        expect(tcp).assertInstanceOf('Object');
710        let bindAddress: socket.NetAddress = {
711          address: '127.0.0.1',
712          port: 0,
713          family: 1
714        };
715        tcp.bind(bindAddress).then(() => {
716          console.info(`${caseName} success`);
717          expectSuccess();
718          done();
719        }).catch((err: BusinessError) => {
720          console.info(`${caseName} fail ${JSON.stringify(err)}`);
721          expectFail();
722          done();
723        }).finally(async () => {
724          await tcp.close();
725          console.info(`${caseName} test end `);
726          done();
727        });
728      } catch (err) {
729        console.info(`${caseName}_catch fail ${JSON.stringify(err)}`);
730        expectFail();
731        console.info(`${caseName} test end `);
732        done();
733      }
734    });
735
736    /* *
737     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_Bind_2000
738     * @tc.name  : testNetworkMgrSocketTCPSocketBind2000
739     * @tc.desc  : Bind IP address and port,Port number is 65535; promise
740     * @tc.size  : MediumTest
741     * @tc.type  : Function
742     * @tc.level : level 2
743     */
744    it('testNetworkMgrSocketTCPSocketBind2000', 0, async (done: Function) => {
745      let caseName: string = 'testNetworkMgrSocketTCPSocketBind2000';
746      try {
747        console.info(`${caseName} test start `);
748        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
749        expect(tcp).assertInstanceOf('Object');
750        let bindAddress: socket.NetAddress = {
751          address: '127.0.0.1',
752          port: 65535,
753          family: 1
754        };
755        tcp.bind(bindAddress).then(() => {
756          console.info(`${caseName} success`);
757          expectSuccess();
758          done();
759        }).catch((err: BusinessError) => {
760          console.info(`${caseName} fail ${JSON.stringify(err)}`);
761          expectFail();
762          done();
763        }).finally(async () => {
764          await tcp.close();
765          console.info(`${caseName} test end `);
766          done();
767        });
768      } catch (err) {
769        console.info(`${caseName}_catch fail ${JSON.stringify(err)}`);
770        expectFail();
771        console.info(`${caseName} test end `);
772        done();
773      }
774    });
775
776    /* *
777     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_Bind_2100
778     * @tc.name  : testNetworkMgrSocketTCPSocketBind2100
779     * @tc.desc  : Bind IP address and port,Port number is 65536; promise
780     * @tc.size  : MediumTest
781     * @tc.type  : Function
782     * @tc.level : level 2
783     */
784    it('testNetworkMgrSocketTCPSocketBind2100', 0, async (done: Function) => {
785      let caseName: string = 'testNetworkMgrSocketTCPSocketBind2100';
786      try {
787        console.info(`${caseName} test start `);
788        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
789        expect(tcp).assertInstanceOf('Object');
790        let bindAddress: socket.NetAddress = {
791          address: '127.0.0.1',
792          port: 65536,
793          family: 1
794        };
795        tcp.bind(bindAddress).then(() => {
796          console.info(`${caseName} success`);
797          expectSuccess();
798          done();
799        }).catch((err: BusinessError) => {
800          console.info(`${caseName} fail ${JSON.stringify(err)}`);
801          expectFail();
802          done();
803        }).finally(async () => {
804          await tcp.close();
805          console.info(`${caseName} test end `);
806          done();
807        });
808      } catch (err) {
809        console.info(`${caseName}_catch fail ${JSON.stringify(err)}`);
810        expectFail();
811        console.info(`${caseName} test end `);
812        done();
813      }
814    });
815
816    /* *
817     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_Bind_2200
818     * @tc.name  : testNetworkMgrSocketTCPSocketBind2200
819     * @tc.desc  : Bind IP address and port, bad family; promise
820     * @tc.size  : MediumTest
821     * @tc.type  : Function
822     * @tc.level : level 2
823     */
824    it('testNetworkMgrSocketTCPSocketBind2200', 0, async (done: Function) => {
825      let caseName: string = 'testNetworkMgrSocketTCPSocketBind2200';
826      try {
827        console.info(`${caseName} test start `);
828        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
829        expect(tcp).assertInstanceOf('Object');
830        let bindAddress: socket.NetAddress = {
831          address: '127.0.0.1',
832          port: 6335,
833          family: 3
834        };
835        tcp.bind(bindAddress).then(() => {
836          console.info(`${caseName} success`);
837          expectSuccess();
838          done();
839        }).catch((err: BusinessError) => {
840          console.info(`${caseName} fail ${JSON.stringify(err)}`);
841          expectFail();
842          done();
843        }).finally(async () => {
844          await tcp.close();
845          console.info(`${caseName} test end `);
846          done();
847        });
848      } catch (err) {
849        console.info(`${caseName}_catch fail ${JSON.stringify(err)}`);
850        expectFail();
851        console.info(`${caseName} test end `);
852        done();
853      }
854    });
855
856    /* *
857     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_Bind_2300
858     * @tc.name  : testNetworkMgrSocketTCPSocketBind2300
859     * @tc.desc  : Bind IP address and port with null; promise
860     * @tc.size  : MediumTest
861     * @tc.type  : Function
862     * @tc.level : level 2
863     */
864    it('testNetworkMgrSocketTCPSocketBind2300', 0, async (done: Function) => {
865      let caseName: string = 'testNetworkMgrSocketTCPSocketBind2300';
866      try {
867        console.info(`${caseName} test start `);
868        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
869        expect(tcp).assertInstanceOf('Object');
870        tcp.bind(null).then(() => {
871          expectFail();
872          done();
873        }).catch((err: BusinessError) => {
874          console.info(`${caseName} fail ${JSON.stringify(err)}`);
875          expect(err.code).assertEqual(401);
876          done();
877        }).finally(() => {
878          console.info(`${caseName} test end`);
879          done();
880        });
881      } catch (err) {
882        console.info(`${caseName}_catch fail ${JSON.stringify(err)}`);
883        expectFail();
884        console.info(`${caseName} test end`);
885        done();
886      }
887    });
888
889    /* *
890     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_Bind_2400
891     * @tc.name  : testNetworkMgrSocketTCPSocketBind2400
892     * @tc.desc  : Bind IP address and port with undefined; promise
893     * @tc.size  : MediumTest
894     * @tc.type  : Function
895     * @tc.level : level 2
896     */
897    it('testNetworkMgrSocketTCPSocketBind2400', 0, async (done: Function) => {
898      let caseName: string = 'testNetworkMgrSocketTCPSocketBind2400';
899      try {
900        console.info(`${caseName} test start `);
901        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
902        expect(tcp).assertInstanceOf('Object');
903        tcp.bind(undefined).then(() => {
904          expectFail();
905          done();
906        }).catch((err: BusinessError) => {
907          console.info(`${caseName} fail ${JSON.stringify(err)}`);
908          expect(err.code).assertEqual(401);
909          done();
910        }).finally(() => {
911          console.info(`${caseName} test end`);
912          done();
913        });
914      } catch (err) {
915        console.info(`${caseName}_catch fail ${JSON.stringify(err)}`);
916        expectFail();
917        console.info(`${caseName} test end`);
918        done();
919      }
920    });
921
922        /* *
923     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_Bind_2500
924     * @tc.name  : testNetworkMgrSocketTCPSocketBind2500
925     * @tc.desc  : Bind IP address and port,Address is Domain name ; promise
926     * @tc.size  : MediumTest
927     * @tc.type  : Function
928     * @tc.level : level 2
929     */
930    it('testNetworkMgrSocketTCPSocketBind2500', 0, async (done: Function) => {
931      let caseName: string = 'testNetworkMgrSocketTCPSocketBind2500';
932      try {
933        console.info(`${caseName} test start `);
934        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
935        expect(tcp).assertInstanceOf('Object');
936        let bindAddress: socket.NetAddress = {
937          address: 'www.baidu.com',
938          port: 80,
939          family: 1
940        };
941        tcp.bind(bindAddress).then(() => {
942          expectFail();
943          done();
944        }).catch((err: BusinessError) => {
945          console.info(`${caseName} fail ${JSON.stringify(err)}`);
946          expectTrue(err.code===401);
947          done();
948        }).finally(() => {
949          console.info(`${caseName} test end`);
950          done();
951        });
952      } catch (err) {
953        console.info(`${caseName}_catch fail ${JSON.stringify(err)}`);
954        expectFail();
955        console.info(`${caseName} test end`);
956        done();
957      }
958    });
959
960    /* *
961     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_Connect_0100
962     * @tc.name  : testNetworkMgrSocketTCPSocketConnect0100
963     * @tc.desc  : Connect to the specified server IP address and port; callback
964     * @tc.size  : MediumTest
965     * @tc.type  : Function
966     * @tc.level : level 2
967     */
968    it('testNetworkMgrSocketTCPSocketConnect0100', 0, async (done: Function) => {
969      let caseName: string = 'testNetworkMgrSocketTCPSocketConnect0100';
970      try {
971        console.info(`${caseName} test start`);
972        await sleep(500);
973        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
974        expect(tcp).assertInstanceOf('Object');
975        let tcpServer: socket.TCPSocketServer = socket.constructTCPSocketServerInstance();
976        expect(tcpServer).assertInstanceOf('Object');
977        let listenAddress: socket.NetAddress = {
978          address: '127.0.0.1',
979          port: 4001,
980          family: 1
981        };
982        await tcpServer.listen(listenAddress);
983        let tcpConnectOptions: socket.TCPConnectOptions = {
984          address:listenAddress
985        };
986        tcp.connect(tcpConnectOptions, async (err: BusinessError) => {
987          if (err) {
988            console.info(`${caseName} fail ${JSON.stringify(err)}`);
989            expectFail();
990          } else {
991            console.info(`${caseName} success`);
992            expectSuccess();
993          }
994          await tcp.close();
995          console.info(`${caseName} test end`);
996          done();
997        });
998      } catch (err) {
999        console.info(`${caseName}_catch fail err:${JSON.stringify(err)}`);
1000        expectFail();
1001        console.info(`${caseName} test end`);
1002        done();
1003      }
1004    });
1005
1006    /* *
1007     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_Connect_0200
1008     * @tc.name  : testNetworkMgrSocketTCPSocketConnect0200
1009     * @tc.desc  : Connect to the specified IP address and port,Input parameter is null; callback
1010     * @tc.size  : MediumTest
1011     * @tc.type  : Function
1012     * @tc.level : level 2
1013     */
1014    it('testNetworkMgrSocketTCPSocketConnect0200', 0, async (done: Function) => {
1015      let caseName: string = 'testNetworkMgrSocketTCPSocketConnect0200';
1016      try {
1017        console.info(`${caseName} test start`);
1018        await sleep(500);
1019        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
1020        expect(tcp).assertInstanceOf('Object');
1021        let bindAddress: socket.NetAddress = {
1022          address: '127.0.0.1',
1023          port: 4002,
1024          family: 1
1025        };
1026        await tcp.bind(bindAddress);
1027        tcp.connect(null, async (err: BusinessError) => {
1028          if (err) {
1029            console.info(`${caseName} fail ${JSON.stringify(err)}`);
1030            expectTrue(err.code===401);
1031          } else {
1032            console.info(`${caseName} success`);
1033            expectFail();
1034          }
1035          await tcp.close();
1036          console.info(`${caseName} test end`);
1037          done();
1038        });
1039      } catch (err) {
1040        console.info(`${caseName}_catch fail ${JSON.stringify(err)}`);
1041        expectFail();
1042        console.info(`${caseName} test end`);
1043        done();
1044      }
1045    });
1046
1047    /* *
1048     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_Connect_0300
1049     * @tc.name  : testNetworkMgrSocketTCPSocketConnect0300
1050     * @tc.desc  : Connect to the specified IP address and port,Input parameter is undefined; callback
1051     * @tc.size  : MediumTest
1052     * @tc.type  : Function
1053     * @tc.level : level 2
1054     */
1055    it('testNetworkMgrSocketTCPSocketConnect0300', 0, async (done: Function) => {
1056      let caseName: string = 'testNetworkMgrSocketTCPSocketConnect0300';
1057      try {
1058        console.info(`${caseName} test start`);
1059        await sleep(500);
1060        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
1061        expect(tcp).assertInstanceOf('Object');
1062        let bindAddress: socket.NetAddress = {
1063          address: '127.0.0.1',
1064          port: 4003,
1065          family: 1
1066        };
1067        await tcp.bind(bindAddress);
1068        tcp.connect(undefined, async (err: BusinessError) => {
1069          if (err) {
1070            console.info(`${caseName} fail ${JSON.stringify(err)}`);
1071            expectTrue(err.code===401);
1072          } else {
1073            console.info(`${caseName} success`);
1074            expectFail();
1075          }
1076          await tcp.close();
1077          console.info(`${caseName} test end`);
1078          done();
1079        });
1080      } catch (err) {
1081        console.info(`${caseName}_catch fail ${JSON.stringify(err)}`);
1082        expectFail();
1083        console.info(`${caseName} test end`);
1084        done();
1085      }
1086    });
1087
1088    /* *
1089     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_Connect_0400
1090     * @tc.name  : testNetworkMgrSocketTCPSocketConnect0400
1091     * @tc.desc  : Connect to the specified IP address and port,Set timeout and address; callback
1092     * @tc.size  : MediumTest
1093     * @tc.type  : Function
1094     * @tc.level : level 2
1095     */
1096    it('testNetworkMgrSocketTCPSocketConnect0400', 0, async (done: Function) => {
1097      let caseName: string = 'testNetworkMgrSocketTCPSocketConnect0400';
1098      try {
1099        console.info(`${caseName} test start`);
1100        await sleep(500);
1101        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
1102        expect(tcp).assertInstanceOf('Object');
1103        let bindAddress: socket.NetAddress = {
1104          address: '127.0.0.1',
1105          port: 4004,
1106          family: 1
1107        };
1108        await tcp.bind(bindAddress);
1109        let tcpConnectOptions: socket.TCPConnectOptions = {
1110          address: {
1111            address: '127.0.0.1',
1112            port: 4004,
1113            family: 1
1114          },
1115          timeout:5000
1116        };
1117        tcp.connect(tcpConnectOptions, async (err: BusinessError) => {
1118          if (err) {
1119            console.info(`${caseName} fail ${JSON.stringify(err)}`);
1120            expectFail();
1121          } else {
1122            console.info(`${caseName} success`);
1123            expectSuccess();
1124          }
1125          await tcp.close();
1126          console.info(`${caseName} test end`);
1127          done();
1128        });
1129      } catch (err) {
1130        console.info(`${caseName}_catch fail ${JSON.stringify(err)}`);
1131        expectFail();
1132        console.info(`${caseName} test end`);
1133        done();
1134      }
1135    });
1136
1137    /* *
1138     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_Connect_0500
1139     * @tc.name  : testNetworkMgrSocketTCPSocketConnect0500
1140     * @tc.desc  : Connect to the specified IP address and port,hour is undefined; callback
1141     * @tc.size  : MediumTest
1142     * @tc.type  : Function
1143     * @tc.level : level 2
1144     */
1145    it('testNetworkMgrSocketTCPSocketConnect0500', 0, async (done: Function) => {
1146      let caseName: string = 'testNetworkMgrSocketTCPSocketConnect0500';
1147      try {
1148        console.info(`${caseName} test start`);
1149        await sleep(500);
1150        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
1151        expect(tcp).assertInstanceOf('Object');
1152        let bindAddress: socket.NetAddress = {
1153          address: '127.0.0.1',
1154          port: 4005,
1155          family: 1
1156        };
1157        await tcp.bind(bindAddress);
1158        let tcpConnectOptions: socket.TCPConnectOptions = {
1159          address: bindAddress,
1160          timeout:undefined
1161        };
1162        tcp.connect(tcpConnectOptions, async (err: BusinessError) => {
1163          if (err) {
1164            console.info(`${caseName} fail ${JSON.stringify(err)}`);
1165            expectFail();
1166          } else {
1167            console.info(`${caseName} success`);
1168            expectSuccess();
1169          }
1170          await tcp.close();
1171          console.info(`${caseName} test end`);
1172          done();
1173        });
1174      } catch (err) {
1175        console.info(`${caseName}_catch fail ${JSON.stringify(err)}`);
1176        expectFail();
1177        console.info(`${caseName} test end`);
1178        done();
1179      }
1180    });
1181
1182    /* *
1183     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_Connect_0600
1184     * @tc.name  : testNetworkMgrSocketTCPSocketConnect0600
1185     * @tc.desc  : Connect to the specified IP address and port, only has an IPV4 address; callback
1186     * @tc.size  : MediumTest
1187     * @tc.type  : Function
1188     * @tc.level : level 2
1189     */
1190    it('testNetworkMgrSocketTCPSocketConnect0600', 0, async (done: Function) => {
1191      let caseName: string = 'testNetworkMgrSocketTCPSocketConnect0600';
1192      try {
1193        console.info(`${caseName} test start`);
1194        await sleep(500);
1195        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
1196        expect(tcp).assertInstanceOf('Object');
1197        let bindAddress: socket.NetAddress = {
1198          address: '127.0.0.1',
1199          port: 4006,
1200          family: 1
1201        };
1202        await tcp.bind(bindAddress);
1203        let tcpConnectOptions: socket.TCPConnectOptions = {
1204          address: {
1205            address: '127.0.0.1'
1206          }
1207        };
1208        tcp.connect(tcpConnectOptions, async (err: BusinessError) => {
1209          if (err) {
1210            console.info(`${caseName} fail ${JSON.stringify(err)}`);
1211            expectTrue(err.code===2301115);
1212          } else {
1213            console.info(`${caseName} success`);
1214            expectFail();
1215          }
1216          await tcp.close();
1217          console.info(`${caseName} test end`);
1218          done();
1219        });
1220      } catch (err) {
1221        console.info(`${caseName}_catch fail ${JSON.stringify(err)}`);
1222        expectFail();
1223        console.info(`${caseName} test end`);
1224        done();
1225      }
1226    });
1227
1228    /* *
1229     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_Connect_0700
1230     * @tc.name  : testNetworkMgrSocketTCPSocketConnect0700
1231     * @tc.desc  : Connect to the specified IP address and port, only has an IPV6 address; callback
1232     * @tc.size  : MediumTest
1233     * @tc.type  : Function
1234     * @tc.level : level 2
1235     */
1236    it('testNetworkMgrSocketTCPSocketConnect0700', 0, async (done: Function) => {
1237      let caseName: string = 'testNetworkMgrSocketTCPSocketConnect0700';
1238      try {
1239        console.info(`${caseName} test start`);
1240        await sleep(500);
1241        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
1242        expect(tcp).assertInstanceOf('Object');
1243        let bindAddress: socket.NetAddress = {
1244          address: 'fe80::b3b:ecb5:77f:88dc%12',
1245          port: 4007,
1246          family: 2
1247        };
1248        await tcp.bind(bindAddress);
1249        let tcpConnectOptions: socket.TCPConnectOptions = {
1250          address: {
1251            address: 'fe80::b3b:ecb5:77f:88dc%12'
1252          }
1253        };
1254        tcp.connect(tcpConnectOptions, async (err: BusinessError) => {
1255          if (err) {
1256            console.info(`${caseName} fail ${JSON.stringify(err)}`);
1257            expectFail();
1258          } else {
1259            console.info(`${caseName} success`);
1260            expectSuccess();
1261          }
1262          await tcp.close();
1263          console.info(`${caseName} test end`);
1264          done();
1265        });
1266      } catch (err) {
1267        console.info(`${caseName}_catch  fail ${JSON.stringify(err)}`);
1268        expectTrue(err.code===2301022);
1269        console.info(`${caseName} test end`);
1270        done();
1271      }
1272    });
1273
1274    /* *
1275     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_Connect_0800
1276     * @tc.name  : testNetworkMgrSocketTCPSocketConnect0800
1277     * @tc.desc  : Connect to the specified IP address and port,The address and protocol  are both IPV6; callback
1278     * @tc.size  : MediumTest
1279     * @tc.type  : Function
1280     * @tc.level : level 2
1281     */
1282    it('testNetworkMgrSocketTCPSocketConnect0800', 0, async (done: Function) => {
1283      let caseName: string = 'testNetworkMgrSocketTCPSocketConnect0800';
1284      try {
1285        console.info(`${caseName} test start`);
1286        await sleep(500);
1287        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
1288        expect(tcp).assertInstanceOf('Object');
1289        let bindAddress: socket.NetAddress = {
1290          address: 'fe80::b3b:ecb5:77f:88dc%12',
1291          port: 4008,
1292          family: 2
1293        };
1294        await tcp.bind(bindAddress);
1295        let tcpConnectOptions: socket.TCPConnectOptions = {
1296          address: bindAddress
1297        };
1298        tcp.connect(tcpConnectOptions, async (err: BusinessError) => {
1299          if (err) {
1300            console.info(`${caseName} fail ${JSON.stringify(err)}`);
1301            expectFail();
1302          } else {
1303            console.info(`${caseName} success`);
1304            expectSuccess();
1305          }
1306          await tcp.close();
1307          console.info(`${caseName} test end`);
1308          done();
1309        });
1310      } catch (err) {
1311        console.info(`${caseName}_catch fail ${JSON.stringify(err)}`);
1312        expectTrue(err.code===2301022);
1313        console.info(`${caseName} test end`);
1314        done();
1315      }
1316    });
1317
1318    /* *
1319     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_Connect_1000
1320     * @tc.name  : testNetworkMgrSocketTCPSocketConnect1000
1321     * @tc.desc  : Connect to the specified IP address and port,bad address; callback
1322     * @tc.size  : MediumTest
1323     * @tc.type  : Function
1324     * @tc.level : level 2
1325     */
1326    it('testNetworkMgrSocketTCPSocketConnect1000', 0, async (done: Function) => {
1327      let caseName: string = 'testNetworkMgrSocketTCPSocketConnect1000';
1328      try {
1329        console.info(`${caseName} test start`);
1330        await sleep(500);
1331        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
1332        expect(tcp).assertInstanceOf('Object');
1333        let bindAddress: socket.NetAddress = {
1334          address: '127.0.0.1',
1335          port: 4010,
1336          family: 1
1337        };
1338        await tcp.bind(bindAddress);
1339        let tcpConnectOptions: socket.TCPConnectOptions = {
1340          address: {
1341            address: '100.0.0.0',
1342            port: 4010,
1343            family: 1
1344          }
1345        };
1346        tcp.connect(tcpConnectOptions, async (err: BusinessError) => {
1347          if (err) {
1348            console.info(`${caseName} fail ${JSON.stringify(err)}`);
1349            expectTrue(err.code===2301022);
1350          } else {
1351            console.info(`${caseName} success`);
1352            expectFail();
1353          }
1354          await tcp.close();
1355          console.info(`${caseName} test end`);
1356          done();
1357        });
1358      } catch (err) {
1359        console.info(`${caseName}_catch fail ${JSON.stringify(err)}`);
1360        expectFail();
1361        console.info(`${caseName} test end`);
1362        done();
1363      }
1364    });
1365
1366    /* *
1367     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_Connect_1100
1368     * @tc.name  : testNetworkMgrSocketTCPSocketConnect1100
1369     * @tc.desc  : Connect to the specified IP address and port,Port is -1; callback
1370     * @tc.size  : MediumTest
1371     * @tc.type  : Function
1372     * @tc.level : level 2
1373     */
1374    it('testNetworkMgrSocketTCPSocketConnect1100', 0, async (done: Function) => {
1375      let caseName: string = 'testNetworkMgrSocketTCPSocketConnect1100';
1376      try {
1377        console.info(`${caseName} test start`);
1378        await sleep(500);
1379        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
1380        expect(tcp).assertInstanceOf('Object');
1381        let bindAddress: socket.NetAddress = {
1382          address: '127.0.0.1',
1383          port: -1,
1384          family: 1
1385        };
1386        await tcp.bind(bindAddress);
1387        let tcpConnectOptions: socket.TCPConnectOptions = {
1388          address: {
1389            address: '127.0.0.1',
1390            port: -1,
1391            family: 1
1392          }
1393        };
1394        tcp.connect(tcpConnectOptions, async (err: BusinessError) => {
1395          if (err) {
1396            console.info(`${caseName} fail ${JSON.stringify(err)}`);
1397            expectFail();
1398          } else {
1399            console.info(`${caseName} success`);
1400            expectSuccess();
1401          }
1402          await tcp.close();
1403          console.info(`${caseName} test end`);
1404          done();
1405        });
1406      } catch (err) {
1407        console.info(`${caseName}_catch fail ${JSON.stringify(err)}`);
1408        expectFail();
1409        console.info(`${caseName} test end`);
1410        done();
1411      }
1412    });
1413
1414    /* *
1415     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_Connect_1200
1416     * @tc.name  : testNetworkMgrSocketTCPSocketConnect1200
1417     * @tc.desc  : Connect to the specified IP address and port,Port is -0; callback
1418     * @tc.size  : MediumTest
1419     * @tc.type  : Function
1420     * @tc.level : level 2
1421     */
1422    it('testNetworkMgrSocketTCPSocketConnect1200', 0, async (done: Function) => {
1423      let caseName: string = 'testNetworkMgrSocketTCPSocketConnect1200';
1424      try {
1425        console.info(`${caseName} test start`);
1426        await sleep(500);
1427        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
1428        expect(tcp).assertInstanceOf('Object');
1429        let bindAddress: socket.NetAddress = {
1430          address: '127.0.0.1',
1431          port: 0,
1432          family: 1
1433        };
1434        await tcp.bind(bindAddress);
1435        let tcpConnectOptions: socket.TCPConnectOptions = {
1436          address: {
1437            address: '127.0.0.1',
1438            port: 0,
1439            family: 1
1440          }
1441        };
1442        tcp.connect(tcpConnectOptions, async (err: BusinessError) => {
1443          if (err.code === 2301115) {
1444            console.info(`${caseName} fail ${JSON.stringify(err)}`);
1445            expectSuccess();
1446          } else {
1447            console.info(`${caseName} success`);
1448            expectFail();
1449          }
1450          await tcp.close();
1451          console.info(`${caseName} test end`);
1452          done();
1453        });
1454      } catch (err) {
1455        console.info(`${caseName}_catch fail ${JSON.stringify(err)}`);
1456        expectFail();
1457        console.info(`${caseName} test end`);
1458        done();
1459      }
1460    });
1461
1462    /* *
1463     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_Connect_1300
1464     * @tc.name  : testNetworkMgrSocketTCPSocketConnect1300
1465     * @tc.desc  : Connect to the specified IP address and port,Port is 65535; callback
1466     * @tc.size  : MediumTest
1467     * @tc.type  : Function
1468     * @tc.level : level 2
1469     */
1470    it('testNetworkMgrSocketTCPSocketConnect1300', 0, async (done: Function) => {
1471      let caseName: string = 'testNetworkMgrSocketTCPSocketConnect1300';
1472      try {
1473        console.info(`${caseName} test start`);
1474        await sleep(500);
1475        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
1476        expect(tcp).assertInstanceOf('Object');
1477        let bindAddress: socket.NetAddress = {
1478          address: '127.0.0.1',
1479          port: 65535,
1480          family: 1
1481        };
1482        await tcp.bind(bindAddress);
1483        let tcpConnectOptions: socket.TCPConnectOptions = {
1484          address: {
1485            address: '127.0.0.1',
1486            port: 65535,
1487            family: 1
1488          }
1489        };
1490        tcp.connect(tcpConnectOptions, async (err: BusinessError) => {
1491          if (err.code === 2301115) {
1492            console.info(`${caseName} fail ${JSON.stringify(err)}`);
1493            expectSuccess();
1494          } else {
1495            console.info(`${caseName} success`);
1496            expectFail();
1497          }
1498          await tcp.close();
1499          console.info(`${caseName} test end`);
1500          done();
1501        });
1502      } catch (err) {
1503        console.info(`${caseName}_catch fail ${JSON.stringify(err)}`);
1504        expectFail();
1505        console.info(`${caseName} test end`);
1506        done();
1507      }
1508    });
1509
1510    /* *
1511     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_Connect_1400
1512     * @tc.name  : testNetworkMgrSocketTCPSocketConnect1400
1513     * @tc.desc  : Connect to the specified IP address and port,Port is 65536; callback
1514     * @tc.size  : MediumTest
1515     * @tc.type  : Function
1516     * @tc.level : level 2
1517     */
1518    it('testNetworkMgrSocketTCPSocketConnect1400', 0, async (done: Function) => {
1519      let caseName: string = 'testNetworkMgrSocketTCPSocketConnect1400';
1520      try {
1521        console.info(`${caseName} test start`);
1522        await sleep(500);
1523        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
1524        expect(tcp).assertInstanceOf('Object');
1525        let bindAddress: socket.NetAddress = {
1526          address: '127.0.0.1',
1527          port: 65536,
1528          family: 1
1529        };
1530        await tcp.bind(bindAddress);
1531        let tcpConnectOptions: socket.TCPConnectOptions = {
1532          address: {
1533            address: '127.0.0.1',
1534            port: 65536,
1535            family: 1
1536          }
1537        };
1538        tcp.connect(tcpConnectOptions, async (err: BusinessError) => {
1539          if (err) {
1540            console.info(`${caseName} success`);
1541            expectSuccess();
1542          } else {
1543            console.info(`${caseName} fail ${JSON.stringify(err)}`);
1544            expectFail();
1545          }
1546          await tcp.close();
1547          console.info(`${caseName} test end`);
1548          done();
1549        });
1550      } catch (err) {
1551        console.info(`${caseName}_catch fail ${JSON.stringify(err)}`);
1552        expectSuccess();
1553        console.info(`${caseName} test end`);
1554        done();
1555      }
1556    });
1557
1558    /* *
1559     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_Connect_1500
1560     * @tc.name  : testNetworkMgrSocketTCPSocketConnect1500
1561     * @tc.desc  : Connect to the specified IP address and port,bad family; callback
1562     * @tc.size  : MediumTest
1563     * @tc.type  : Function
1564     * @tc.level : level 2
1565     */
1566    it('testNetworkMgrSocketTCPSocketConnect1500', 0, async (done: Function) => {
1567      let caseName: string = 'testNetworkMgrSocketTCPSocketConnect1500';
1568      try {
1569        console.info(`${caseName} test start`);
1570        await sleep(500);
1571        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
1572        expect(tcp).assertInstanceOf('Object');
1573        let bindAddress: socket.NetAddress = {
1574          address: '127.0.0.1',
1575          port: 4015,
1576          family: 1
1577        };
1578        await tcp.bind(bindAddress);
1579        let tcpConnectOptions: socket.TCPConnectOptions = {
1580          address: {
1581            address: '127.0.0.1',
1582            port: 4015,
1583            family: 3
1584          }
1585        };
1586        tcp.connect(tcpConnectOptions, async (err: BusinessError) => {
1587          if (err) {
1588            console.info(`${caseName} fail ${JSON.stringify(err)}`);
1589            expectFail();
1590          } else {
1591            console.info(`${caseName} success`);
1592            expectSuccess();
1593          }
1594          await tcp.close();
1595          console.info(`${caseName} test end`);
1596          done();
1597        });
1598      } catch (err) {
1599        console.info(`${caseName}_catch fail ${JSON.stringify(err)}`);
1600        expectFail();
1601        console.info(`${caseName} test end`);
1602        done();
1603      }
1604    });
1605
1606    /* *
1607     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_Connect_1600
1608     * @tc.name  : testNetworkMgrSocketTCPSocketConnect1600
1609     * @tc.desc  : Connect to the specified IP address and port,Connect without binding or listening; callback
1610     * @tc.size  : MediumTest
1611     * @tc.type  : Function
1612     * @tc.level : level 2
1613     */
1614    it('testNetworkMgrSocketTCPSocketConnect1600', 0, async (done: Function) => {
1615      let caseName: string = 'testNetworkMgrSocketTCPSocketConnect1600';
1616      try {
1617        console.info(`${caseName} test start`);
1618        await sleep(500);
1619        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
1620        expect(tcp).assertInstanceOf('Object');
1621        let tcpConnectOptions: socket.TCPConnectOptions = {
1622          address: {
1623            address: '127.0.0.1',
1624            port: 4016,
1625            family: 1
1626          }
1627        };
1628        tcp.connect(tcpConnectOptions, async (err: BusinessError) => {
1629          if (err) {
1630            console.info(`${caseName} fail ${JSON.stringify(err)}`);
1631            expectTrue(err.code===2301115);
1632          } else {
1633            console.info(`${caseName} success`);
1634            expectSuccess();
1635          }
1636          console.info(`${caseName} test end`);
1637          done();
1638        });
1639      } catch (err) {
1640        console.info(`${caseName}_catch fail ${JSON.stringify(err)}`);
1641        expectFail();
1642        console.info(`${caseName} test end`);
1643        done();
1644      }
1645    });
1646
1647    /* *
1648     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_Connect_1700
1649     * @tc.name  : testNetworkMgrSocketTCPSocketConnect1700
1650     * @tc.desc  : Connect to the specified server IP address and port; promise
1651     * @tc.size  : MediumTest
1652     * @tc.type  : Function
1653     * @tc.level : level 2
1654     */
1655    it('testNetworkMgrSocketTCPSocketConnect1700', 0, async (done: Function) => {
1656      let caseName: string = 'testNetworkMgrSocketTCPSocketConnect1700';
1657      try {
1658        console.info(`${caseName} test start`);
1659        await sleep(500);
1660        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
1661        expect(tcp).assertInstanceOf('Object');
1662        let tcpServer: socket.TCPSocketServer = socket.constructTCPSocketServerInstance();
1663        expect(tcpServer).assertInstanceOf('Object');
1664        let listenAddress: socket.NetAddress = {
1665          address: '127.0.0.1',
1666          port: 4017
1667        };
1668        await tcpServer.listen(listenAddress);
1669        let tcpConnectOptions: socket.TCPConnectOptions = {
1670          address: {
1671            address: '127.0.0.1',
1672            port: 4017
1673          },
1674        };
1675        tcp.connect(tcpConnectOptions).then(() => {
1676          console.info(`${caseName} success`);
1677          expectSuccess();
1678          done();
1679        }).catch((err: BusinessError) => {
1680          console.info(`${caseName}  fail err:${JSON.stringify(err)}`);
1681          expectFail();
1682          done();
1683        }).finally(async () => {
1684          await tcp.close();
1685          console.info(`${caseName} test end`);
1686          done();
1687        });
1688      } catch (err) {
1689        console.info(`${caseName}_catch fail err:${JSON.stringify(err)}`);
1690        expectFail();
1691        console.info(`${caseName} test end`);
1692        done();
1693      }
1694    });
1695
1696    /* *
1697     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_Connect_1800
1698     * @tc.name  : testNetworkMgrSocketTCPSocketConnect1800
1699     * @tc.desc  : Connect to the specified IP address and port,Input parameter is null; promise
1700     * @tc.size  : MediumTest
1701     * @tc.type  : Function
1702     * @tc.level : level 2
1703     */
1704    it('testNetworkMgrSocketTCPSocketConnect1800', 0, async (done: Function) => {
1705      let caseName: string = 'testNetworkMgrSocketTCPSocketConnect1800';
1706      try {
1707        console.info(`${caseName} test start`);
1708        await sleep(500);
1709        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
1710        expect(tcp).assertInstanceOf('Object');
1711        let bindAddress: socket.NetAddress = {
1712          address: '127.0.0.1',
1713          port: 4018
1714        };
1715        await tcp.bind(bindAddress);
1716        tcp.connect(null).then(() => {
1717          console.info(`${caseName} success`);
1718          expectFail();
1719          done();
1720        }).catch((err: BusinessError) => {
1721          console.info(`${caseName} fail err:${JSON.stringify(err)}`);
1722          expectTrue(err.code===401);
1723          done();
1724        }).finally(async () => {
1725          await tcp.close();
1726          console.info(`${caseName} test end`);
1727          done();
1728        });
1729      } catch (err) {
1730        console.info(`${caseName}_catch fail err:${JSON.stringify(err)}`);
1731        expectFail();
1732        console.info(`${caseName} test end`);
1733        done();
1734      }
1735    });
1736
1737    /* *
1738     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_Connect_1900
1739     * @tc.name  : testNetworkMgrSocketTCPSocketConnect1900
1740     * @tc.desc  : Connect to the specified IP address and port,Input parameter is undefined; promise
1741     * @tc.size  : MediumTest
1742     * @tc.type  : Function
1743     * @tc.level : level 2
1744     */
1745    it('testNetworkMgrSocketTCPSocketConnect1900', 0, async (done: Function) => {
1746      let caseName: string = 'testNetworkMgrSocketTCPSocketConnect1900';
1747      try {
1748        console.info(`${caseName} test start`);
1749        await sleep(500);
1750        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
1751        expect(tcp).assertInstanceOf('Object');
1752        let bindAddress: socket.NetAddress = {
1753          address: '127.0.0.1',
1754          port: 4019
1755        };
1756        await tcp.bind(bindAddress);
1757        tcp.connect(undefined).then(() => {
1758          console.info(`${caseName} success`);
1759          expectFail();
1760          done();
1761        }).catch((err: BusinessError) => {
1762          console.info(`${caseName} fail err:${JSON.stringify(err)}`);
1763          expectTrue(err.code===401);
1764          done();
1765        }).finally(async () => {
1766          await tcp.close();
1767          console.info(`${caseName} test end`);
1768          done();
1769        });
1770      } catch (err) {
1771        console.info(`${caseName}_catch fail err:${JSON.stringify(err)}`);
1772        expectFail();
1773        console.info(`${caseName} test end`);
1774        done();
1775      }
1776    });
1777
1778    /* *
1779     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_Connect_2000
1780     * @tc.name  : testNetworkMgrSocketTCPSocketConnect2000
1781     * @tc.desc  : Connect to the specified IP address and port,Set timeout and address; promise
1782     * @tc.size  : MediumTest
1783     * @tc.type  : Function
1784     * @tc.level : level 2
1785     */
1786    it('testNetworkMgrSocketTCPSocketConnect2000', 0, async (done: Function) => {
1787      let caseName: string = 'testNetworkMgrSocketTCPSocketConnect2000';
1788      try {
1789        console.info(`${caseName} test start`);
1790        await sleep(500);
1791        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
1792        expect(tcp).assertInstanceOf('Object');
1793        let bindAddress: socket.NetAddress = {
1794          address: '127.0.0.1',
1795          port: 4020,
1796          family:1
1797        };
1798        await tcp.bind(bindAddress);
1799        let tcpConnectOptions: socket.TCPConnectOptions = {
1800          address:  {
1801            address: '127.0.0.1',
1802            port: 4020,
1803            family:1
1804          },
1805          timeout:5000
1806        };
1807        tcp.connect(tcpConnectOptions).then(() => {
1808          console.info(`${caseName} success`);
1809          expectSuccess();
1810          done();
1811        }).catch((err: BusinessError) => {
1812          console.info(`${caseName}  fail err:${JSON.stringify(err)}`);
1813          expectFail();
1814          done();
1815        }).finally(async () => {
1816          await tcp.close();
1817          console.info(`${caseName} test end`);
1818          done();
1819        });
1820      } catch (err) {
1821        console.info(`${caseName}_catch fail err:${JSON.stringify(err)}`);
1822        expectFail();
1823        console.info(`${caseName} test end`);
1824        done();
1825      }
1826    });
1827
1828    /* *
1829     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_Connect_2100
1830     * @tc.name  : testNetworkMgrSocketTCPSocketConnect2100
1831     * @tc.desc  : Connect to the specified IP address and port,hour is undefined; promise
1832     * @tc.size  : MediumTest
1833     * @tc.type  : Function
1834     * @tc.level : level 2
1835     */
1836    it('testNetworkMgrSocketTCPSocketConnect2100', 0, async (done: Function) => {
1837      let caseName: string = 'testNetworkMgrSocketTCPSocketConnect2100';
1838      try {
1839        console.info(`${caseName} test start`);
1840        await sleep(500);
1841        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
1842        expect(tcp).assertInstanceOf('Object');
1843        let bindAddress: socket.NetAddress = {
1844          address: '127.0.0.1',
1845          port: 4021,
1846          family:1
1847        };
1848        await tcp.bind(bindAddress);
1849        let tcpConnectOptions: socket.TCPConnectOptions = {
1850          address:  {
1851            address: '127.0.0.1',
1852            port: 4021
1853          },
1854          timeout:undefined
1855        };
1856        tcp.connect(tcpConnectOptions).then(() => {
1857          console.info(`${caseName} success`);
1858          expectSuccess();
1859          done();
1860        }).catch((err: BusinessError) => {
1861          console.info(`${caseName}  fail err:${JSON.stringify(err)}`);
1862          expectFail();
1863          done();
1864        }).finally(async () => {
1865          await tcp.close();
1866          console.info(`${caseName} test end`);
1867          done();
1868        });
1869      } catch (err) {
1870        console.info(`${caseName}_catch fail err:${JSON.stringify(err)}`);
1871        expectFail();
1872        console.info(`${caseName} test end`);
1873        done();
1874      }
1875    });
1876
1877    /* *
1878     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_Connect_2200
1879     * @tc.name  : testNetworkMgrSocketTCPSocketConnect2200
1880     * @tc.desc  : Connect to the specified IP address and port, only has an IPV4 address; promise
1881     * @tc.size  : MediumTest
1882     * @tc.type  : Function
1883     * @tc.level : level 2
1884     */
1885    it('testNetworkMgrSocketTCPSocketConnect2200', 0, async (done: Function) => {
1886      let caseName: string = 'testNetworkMgrSocketTCPSocketConnect2200';
1887      try {
1888        console.info(`${caseName} test start`);
1889        await sleep(500);
1890        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
1891        expect(tcp).assertInstanceOf('Object');
1892        let bindAddress: socket.NetAddress = {
1893          address: '127.0.0.1',
1894          port: 4022,
1895          family:1
1896        };
1897        await tcp.bind(bindAddress);
1898        let tcpConnectOptions: socket.TCPConnectOptions = {
1899          address: {
1900            address: '127.0.0.1'
1901          }
1902        };
1903        tcp.connect(tcpConnectOptions).then(() => {
1904          console.info(`${caseName} success`);
1905          expectFail();
1906          done();
1907        }).catch((err: BusinessError) => {
1908          console.info(`${caseName} fail err:${JSON.stringify(err)}`);
1909          expectTrue(err.code===2301115);
1910          done();
1911        }).finally(async () => {
1912          await tcp.close();
1913          console.info(`${caseName} test end`);
1914          done();
1915        });
1916      } catch (err) {
1917        console.info(`${caseName}_catch fail err:${JSON.stringify(err)}`);
1918        expectFail();
1919        console.info(`${caseName} test end`);
1920        done();
1921      }
1922    });
1923
1924    /* *
1925     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_Connect_2300
1926     * @tc.name  : testNetworkMgrSocketTCPSocketConnect2300
1927     * @tc.desc  : Connect to the specified IP address and port, only has an IPV6 address; promise
1928     * @tc.size  : MediumTest
1929     * @tc.type  : Function
1930     * @tc.level : level 2
1931     */
1932    it('testNetworkMgrSocketTCPSocketConnect2300', 0, async (done: Function) => {
1933      let caseName: string = 'testNetworkMgrSocketTCPSocketConnect2300';
1934      try {
1935        console.info(`${caseName} test start`);
1936        await sleep(500);
1937        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
1938        expect(tcp).assertInstanceOf('Object');
1939        let bindAddress: socket.NetAddress = {
1940          address: 'fe80::b3b:ecb5:77f:88dc%12',
1941          port: 4023,
1942          family:2
1943        };
1944        await tcp.bind(bindAddress);
1945        let tcpConnectOptions: socket.TCPConnectOptions = {
1946          address: {
1947            address:'fe80::b3b:ecb5:77f:88dc%12'
1948          }
1949        };
1950        tcp.connect(tcpConnectOptions).then(() => {
1951          console.info(`${caseName} success`);
1952          expectSuccess();
1953          done();
1954        }).catch((err: BusinessError) => {
1955          console.info(`${caseName}  fail err:${JSON.stringify(err)}`);
1956          expectFail();
1957          done();
1958        }).finally(async () => {
1959          await tcp.close();
1960          console.info(`${caseName} test end`);
1961          done();
1962        });
1963      } catch (err) {
1964        console.info(`${caseName}_catch fail err:${JSON.stringify(err)}`);
1965        expectTrue(err.code===2301022);
1966        console.info(`${caseName} test end`);
1967        done();
1968      }
1969    });
1970
1971    /* *
1972     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_Connect_2400
1973     * @tc.name  : testNetworkMgrSocketTCPSocketConnect2400
1974     * @tc.desc  : Connect to the specified IP address and port,The address and protocol  are both IPV6; promise
1975     * @tc.size  : MediumTest
1976     * @tc.type  : Function
1977     * @tc.level : level 2
1978     */
1979    it('testNetworkMgrSocketTCPSocketConnect2400', 0, async (done: Function) => {
1980      let caseName: string = 'testNetworkMgrSocketTCPSocketConnect2400';
1981      try {
1982        console.info(`${caseName} test start`);
1983        await sleep(500);
1984        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
1985        expect(tcp).assertInstanceOf('Object');
1986        let bindAddress: socket.NetAddress = {
1987          address: 'fe80::b3b:ecb5:77f:88dc%12',
1988          port: 4024,
1989          family:2
1990        };
1991        await tcp.bind(bindAddress);
1992        let tcpConnectOptions: socket.TCPConnectOptions = {
1993          address: bindAddress
1994        };
1995        tcp.connect(tcpConnectOptions).then(() => {
1996          console.info(`${caseName} success`);
1997          expectSuccess();
1998          done();
1999        }).catch((err: BusinessError) => {
2000          console.info(`${caseName}  fail err:${JSON.stringify(err)}`);
2001          expectFail();
2002          done();
2003        }).finally(async () => {
2004          await tcp.close();
2005          console.info(`${caseName} test end`);
2006          done();
2007        });
2008      } catch (err) {
2009        console.info(`${caseName}_catch fail err:${JSON.stringify(err)}`);
2010        expectTrue(err.code===2301022);
2011        console.info(`${caseName} test end`);
2012        done();
2013      }
2014    });
2015
2016    /* *
2017     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_Connect_2500
2018     * @tc.name  : testNetworkMgrSocketTCPSocketConnect2500
2019     * @tc.desc  : Connect to the specified IP address and port,Address and protocol inversion; promise
2020     * @tc.size  : MediumTest
2021     * @tc.type  : Function
2022     * @tc.level : level 2
2023     */
2024    it('testNetworkMgrSocketTCPSocketConnect2500', 0, async (done: Function) => {
2025      let caseName: string = 'testNetworkMgrSocketTCPSocketConnect2500';
2026      try {
2027        console.info(`${caseName} test start`);
2028        await sleep(500);
2029        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
2030        expect(tcp).assertInstanceOf('Object');
2031        let bindAddress: socket.NetAddress = {
2032          address: '127.0.0.1',
2033          port: 4025,
2034          family:1
2035        };
2036        await tcp.bind(bindAddress);
2037        let tcpConnectOptions: socket.TCPConnectOptions = {
2038          address: {
2039            address: '127.0.0.1',
2040            port: 4025,
2041            family: 2
2042          }
2043        };
2044        tcp.connect(tcpConnectOptions).then(() => {
2045          console.info(`${caseName} success`);
2046          expectFail();
2047          done();
2048        }).catch((err: BusinessError) => {
2049          console.info(`${caseName} fail err:${JSON.stringify(err)}`);
2050          expectTrue(err.code===401);
2051          done();
2052        }).finally(async () => {
2053          await tcp.close();
2054          console.info(`${caseName} test end`);
2055          done();
2056        });
2057      } catch (err) {
2058        console.info(`${caseName}_catch fail err:${JSON.stringify(err)}`);
2059        expectFail();
2060        console.info(`${caseName} test end`);
2061        done();
2062      }
2063    });
2064
2065    /* *
2066     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_Connect_2600
2067     * @tc.name  : testNetworkMgrSocketTCPSocketConnect2600
2068     * @tc.desc  : Connect to the specified IP address and port,bad address; promise
2069     * @tc.size  : MediumTest
2070     * @tc.type  : Function
2071     * @tc.level : level 2
2072     */
2073    it('testNetworkMgrSocketTCPSocketConnect2600', 0, async (done: Function) => {
2074      let caseName: string = 'testNetworkMgrSocketTCPSocketConnect2600';
2075      try {
2076        console.info(`${caseName} test start`);
2077        await sleep(500);
2078        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
2079        expect(tcp).assertInstanceOf('Object');
2080        let bindAddress: socket.NetAddress = {
2081          address: '127.0.0.1',
2082          port: 4026,
2083          family:1
2084        };
2085        await tcp.bind(bindAddress);
2086        let tcpConnectOptions: socket.TCPConnectOptions = {
2087          address: {
2088            address: '100.0.0.0',
2089            port: 4026,
2090            family: 1
2091          }
2092        };
2093        tcp.connect(tcpConnectOptions).then(() => {
2094          console.info(`${caseName} success`);
2095          expectFail();
2096          done();
2097        }).catch((err: BusinessError) => {
2098          console.info(`${caseName}  fail err:${JSON.stringify(err)}`);
2099          expectTrue(err.code===2301022);
2100          done();
2101        }).finally(async () => {
2102          await tcp.close();
2103          console.info(`${caseName} test end`);
2104          done();
2105        });
2106      } catch (err) {
2107        console.info(`${caseName}_catch fail err:${JSON.stringify(err)}`);
2108        expectFail();
2109        console.info(`${caseName} test end`);
2110        done();
2111      }
2112    });
2113
2114    /* *
2115     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_Connect_2700
2116     * @tc.name  : testNetworkMgrSocketTCPSocketConnect2700
2117     * @tc.desc  : Connect to the specified IP address and port,Port is -1; promise
2118     * @tc.size  : MediumTest
2119     * @tc.type  : Function
2120     * @tc.level : level 2
2121     */
2122    it('testNetworkMgrSocketTCPSocketConnect2700', 0, async (done: Function) => {
2123      let caseName: string = 'testNetworkMgrSocketTCPSocketConnect2700';
2124      try {
2125        console.info(`${caseName} test start`);
2126        await sleep(500);
2127        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
2128        expect(tcp).assertInstanceOf('Object');
2129        let bindAddress: socket.NetAddress = {
2130          address: '127.0.0.1',
2131          port: -1,
2132          family:1
2133        };
2134        await tcp.bind(bindAddress);
2135        let tcpConnectOptions: socket.TCPConnectOptions = {
2136          address: {
2137            address: '127.0.0.1',
2138            port: -1,
2139            family: 1
2140          }
2141        };
2142        tcp.connect(tcpConnectOptions).then(() => {
2143          console.info(`${caseName} success`);
2144          expectFail();
2145          done();
2146        }).catch((err: BusinessError) => {
2147          console.info(`${caseName}  fail err:${JSON.stringify(err)}`);
2148          expectSuccess();
2149          done();
2150        }).finally(async () => {
2151          await tcp.close();
2152          console.info(`${caseName} test end`);
2153          done();
2154        });
2155      } catch (err) {
2156        console.info(`${caseName}_catch fail err:${JSON.stringify(err)}`);
2157        expectFail();
2158        console.info(`${caseName} test end`);
2159        done();
2160      }
2161    });
2162
2163    /* *
2164     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_Connect_2800
2165     * @tc.name  : testNetworkMgrSocketTCPSocketConnect2800
2166     * @tc.desc  : Connect to the specified IP address and port,Port is -0; promise
2167     * @tc.size  : MediumTest
2168     * @tc.type  : Function
2169     * @tc.level : level 2
2170     */
2171    it('testNetworkMgrSocketTCPSocketConnect2800', 0, async (done: Function) => {
2172      let caseName: string = 'testNetworkMgrSocketTCPSocketConnect2800';
2173      try {
2174        console.info(`${caseName} test start`);
2175        await sleep(500);
2176        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
2177        expect(tcp).assertInstanceOf('Object');
2178        let bindAddress: socket.NetAddress = {
2179          address: '127.0.0.1',
2180          port: 0,
2181          family:1
2182        };
2183        await tcp.bind(bindAddress);
2184        let tcpConnectOptions: socket.TCPConnectOptions = {
2185          address: {
2186            address: '127.0.0.1',
2187            port: 0,
2188            family: 1
2189          }
2190        };
2191        tcp.connect(tcpConnectOptions).then(() => {
2192          console.info(`${caseName} success`);
2193          expectFail();
2194          done();
2195        }).catch((err: BusinessError) => {
2196          console.info(`${caseName}  fail err:${JSON.stringify(err)}`);
2197          expectSuccess();
2198          done();
2199        }).finally(async () => {
2200          await tcp.close();
2201          console.info(`${caseName} test end`);
2202          done();
2203        });
2204      } catch (err) {
2205        console.info(`${caseName}_catch fail err:${JSON.stringify(err)}`);
2206        expectFail();
2207        console.info(`${caseName} test end`);
2208        done();
2209      }
2210    });
2211
2212    /* *
2213     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_Connect_2900
2214     * @tc.name  : testNetworkMgrSocketTCPSocketConnect2900
2215     * @tc.desc  : Connect to the specified IP address and port,Port is 65535; promise
2216     * @tc.size  : MediumTest
2217     * @tc.type  : Function
2218     * @tc.level : level 2
2219     */
2220    it('testNetworkMgrSocketTCPSocketConnect2900', 0, async (done: Function) => {
2221      let caseName: string = 'testNetworkMgrSocketTCPSocketConnect2900';
2222      try {
2223        console.info(`${caseName} test start`);
2224        await sleep(500);
2225        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
2226        expect(tcp).assertInstanceOf('Object');
2227        let bindAddress: socket.NetAddress = {
2228          address: '127.0.0.1',
2229          port: 65535,
2230          family:1
2231        };
2232        await tcp.bind(bindAddress);
2233        let tcpConnectOptions: socket.TCPConnectOptions = {
2234          address: {
2235            address: '127.0.0.1',
2236            port: 65535,
2237            family: 1
2238          }
2239        };
2240        tcp.connect(tcpConnectOptions).then(() => {
2241          console.info(`${caseName} success`);
2242          expectFail();
2243          done();
2244        }).catch((err: BusinessError) => {
2245          console.info(`${caseName} fail err:${JSON.stringify(err)}`);
2246          expectSuccess();
2247          done();
2248        }).finally(async () => {
2249          await tcp.close();
2250          console.info(`${caseName} test end`);
2251          done();
2252        });
2253      } catch (err) {
2254        console.info(`${caseName}_catch fail err:${JSON.stringify(err)}`);
2255        expectFail();
2256        console.info(`${caseName} test end`);
2257        done();
2258      }
2259    });
2260
2261    /* *
2262     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_Connect_3000
2263     * @tc.name  : testNetworkMgrSocketTCPSocketConnect3000
2264     * @tc.desc  : Connect to the specified IP address and port,Port is 65536; promise
2265     * @tc.size  : MediumTest
2266     * @tc.type  : Function
2267     * @tc.level : level 2
2268     */
2269    it('testNetworkMgrSocketTCPSocketConnect3000', 0, async (done: Function) => {
2270      let caseName: string = 'testNetworkMgrSocketTCPSocketConnect3000';
2271      try {
2272        console.info(`${caseName} test start`);
2273        await sleep(500);
2274        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
2275        expect(tcp).assertInstanceOf('Object');
2276        let bindAddress: socket.NetAddress = {
2277          address: '127.0.0.1',
2278          port: 65536,
2279          family:1
2280        };
2281        await tcp.bind(bindAddress);
2282        let tcpConnectOptions: socket.TCPConnectOptions = {
2283          address: {
2284            address: '127.0.0.1',
2285            port: 65536,
2286            family: 1
2287          }
2288        };
2289        tcp.connect(tcpConnectOptions).then(() => {
2290          console.info(`${caseName} success`);
2291          expectFail();
2292          done();
2293        }).catch((err: BusinessError) => {
2294          console.info(`${caseName} fail err:${JSON.stringify(err)}`);
2295          expectSuccess();
2296          done();
2297        }).finally(async () => {
2298          await tcp.close();
2299          console.info(`${caseName} test end`);
2300          done();
2301        });
2302      } catch (err) {
2303        console.info(`${caseName}_catch fail err:${JSON.stringify(err)}`);
2304        expectFail();
2305        console.info(`${caseName} test end`);
2306        done();
2307      }
2308    });
2309
2310    /* *
2311     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_Connect_3100
2312     * @tc.name  : testNetworkMgrSocketTCPSocketConnect3100
2313     * @tc.desc  : Connect to the specified IP address and port,bad family; promise
2314     * @tc.size  : MediumTest
2315     * @tc.type  : Function
2316     * @tc.level : level 2
2317     */
2318    it('testNetworkMgrSocketTCPSocketConnect3100', 0, async (done: Function) => {
2319      let caseName: string = 'testNetworkMgrSocketTCPSocketConnect3100';
2320      try {
2321        console.info(`${caseName} test start`);
2322        await sleep(500);
2323        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
2324        expect(tcp).assertInstanceOf('Object');
2325        let bindAddress: socket.NetAddress = {
2326          address: '127.0.0.1',
2327          port: 4031,
2328          family:1
2329        };
2330        await tcp.bind(bindAddress);
2331        let tcpConnectOptions: socket.TCPConnectOptions = {
2332          address: {
2333            address: '127.0.0.1',
2334            port: 4031,
2335            family: 3
2336          }
2337        };
2338        tcp.connect(tcpConnectOptions).then(() => {
2339          console.info(`${caseName} success`);
2340          expectSuccess();
2341          done();
2342        }).catch((err: BusinessError) => {
2343          console.info(`${caseName} fail err:${JSON.stringify(err)}`);
2344          expectFail();
2345          done();
2346        }).finally(async () => {
2347          await tcp.close();
2348          console.info(`${caseName} test end`);
2349          done();
2350        });
2351      } catch (err) {
2352        console.info(`${caseName}_catch fail err:${JSON.stringify(err)}`);
2353        expectFail();
2354        console.info(`${caseName} test end`);
2355        done();
2356      }
2357    });
2358
2359    /* *
2360     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_Connect_3200
2361     * @tc.name  : testNetworkMgrSocketTCPSocketConnect3200
2362     * @tc.desc  : Connect to the specified IP address and port,Connect without binding or listening; promise
2363     * @tc.size  : MediumTest
2364     * @tc.type  : Function
2365     * @tc.level : level 2
2366     */
2367    it('testNetworkMgrSocketTCPSocketConnect3200', 0, async (done: Function) => {
2368      let caseName: string = 'testNetworkMgrSocketTCPSocketConnect3200';
2369      try {
2370        console.info(`${caseName} test start`);
2371        await sleep(500);
2372        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
2373        expect(tcp).assertInstanceOf('Object');
2374        let tcpConnectOptions: socket.TCPConnectOptions = {
2375          address: {
2376            address: '127.0.0.1',
2377            port: 4032,
2378            family: 1
2379          }
2380        };
2381        tcp.connect(tcpConnectOptions).then(() => {
2382          console.info(`${caseName} success`);
2383          expectFail();
2384          done();
2385        }).catch((err: BusinessError) => {
2386          console.info(`${caseName}  fail err:${JSON.stringify(err)}`);
2387          expectTrue(err.code===2301115);
2388          done();
2389        }).finally(async () => {
2390          await tcp.close();
2391          console.info(`${caseName} test end`);
2392          done();
2393        });
2394      } catch (err) {
2395        console.info(`${caseName}_catch fail err:${JSON.stringify(err)}`);
2396        expectFail();
2397        console.info(`${caseName} test end`);
2398        done();
2399      }
2400    });
2401
2402    /* *
2403     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_Send_0100
2404     * @tc.name  : testNetworkMgrSocketTCPSocketSend0100
2405     * @tc.desc  : Sending data through TCP Socket connection,To the client; callback
2406     * @tc.size  : MediumTest
2407     * @tc.type  : Function
2408     * @tc.level : level 2
2409     */
2410    it('testNetworkMgrSocketTCPSocketSend0100', 0, async (done: Function) => {
2411      let caseName: string = 'testNetworkMgrSocketTCPSocketSend0100';
2412      try {
2413        console.info(`${caseName} test start`);
2414        await sleep(500);
2415        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
2416        expect(tcp).assertInstanceOf('Object');
2417        let bindAddress: socket.NetAddress = {
2418          address: '127.0.0.1',
2419          port: 4033
2420        };
2421        await tcp.bind(bindAddress);
2422        let tcpConnectOptions: socket.TCPConnectOptions = {
2423          address: bindAddress
2424        };
2425        await tcp.connect(tcpConnectOptions);
2426        let tcpSendOptions: socket.TCPSendOptions = {
2427          data: 'Hello, server!'
2428        };
2429        tcp.send(tcpSendOptions, async (err: BusinessError) => {
2430          if (err) {
2431            console.info(`${caseName} fail err:${JSON.stringify(err)}`);
2432            expectFail();
2433          } else {
2434            console.info(`${caseName} success`);
2435            expectSuccess();
2436          }
2437          await tcp.close();
2438          console.info(`${caseName} test end`);
2439          done();
2440        });
2441      } catch (err) {
2442        console.info(`${caseName}_catch fail err:${JSON.stringify(err)}`);
2443        expectFail();
2444        console.info(`${caseName} test end`);
2445        done();
2446      }
2447    });
2448
2449    /* *
2450     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_Send_0200
2451     * @tc.name  : testNetworkMgrSocketTCPSocketSend0200
2452     * @tc.desc  : Sending data through TCP Socket connection,To the server; callback
2453     * @tc.size  : MediumTest
2454     * @tc.type  : Function
2455     * @tc.level : level 2
2456     */
2457    it('testNetworkMgrSocketTCPSocketSend0200', 0, async (done: Function) => {
2458      let caseName: string = 'testNetworkMgrSocketTCPSocketSend0200';
2459      try {
2460        console.info(`${caseName} test start`);
2461        await sleep(500);
2462        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
2463        let tcpServer: socket.TCPSocketServer = socket.constructTCPSocketServerInstance();
2464        let listenAddress: socket.NetAddress = {
2465          address: '127.0.0.1',
2466          port: 4034
2467        };
2468        await tcpServer.listen(listenAddress);
2469        let tcpConnectOptions: socket.TCPConnectOptions = {
2470          address: listenAddress
2471        };
2472        await tcp.connect(tcpConnectOptions);
2473        let tcpSendOptions: socket.TCPSendOptions = {
2474          data: 'Hello, server!'
2475        };
2476        tcp.send(tcpSendOptions, async (err: BusinessError) => {
2477          if (err) {
2478            console.info(`${caseName} fail err:${JSON.stringify(err)}`);
2479            expectFail();
2480          } else {
2481            console.info(`${caseName} success`);
2482            expectSuccess();
2483          }
2484          await tcp.close();
2485          console.info(`${caseName} test end`);
2486          done();
2487        });
2488      } catch (err) {
2489        console.info(`${caseName}_catch fail err:${JSON.stringify(err)}`);
2490        expectFail();
2491        console.info(`${caseName} test end`);
2492        done();
2493      }
2494    });
2495
2496    /* *
2497     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_Send_0400
2498     * @tc.name  : testNetworkMgrSocketTCPSocketSend0400
2499     * @tc.desc  : Sending data through TCP Socket connection,Input parameter is null; callback
2500     * @tc.size  : MediumTest
2501     * @tc.type  : Function
2502     * @tc.level : level 2
2503     */
2504    it('testNetworkMgrSocketTCPSocketSend0400', 0, async (done: Function) => {
2505      let caseName: string = 'testNetworkMgrSocketTCPSocketSend0400';
2506      try {
2507        console.info(`${caseName} test start`);
2508        await sleep(500);
2509        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
2510        expect(tcp).assertInstanceOf('Object');
2511        let bindAddress: socket.NetAddress = {
2512          address: '127.0.0.1',
2513          port: 4036
2514        };
2515        await tcp.bind(bindAddress);
2516        let tcpConnectOptions: socket.TCPConnectOptions = {
2517          address: bindAddress
2518        };
2519        await tcp.connect(tcpConnectOptions);
2520        tcp.send(null, async (err: BusinessError) => {
2521          if (err) {
2522            console.info(`${caseName} fail err:${JSON.stringify(err)}`);
2523            expectTrue(err.code===401);
2524            done();
2525          } else {
2526            console.info(`${caseName} success`);
2527            expectFail();
2528            done();
2529          }
2530          await tcp.close();
2531          console.info(`${caseName} test end`);
2532          done();
2533        });
2534      } catch (err) {
2535        console.info(`${caseName}_catch fail err:${JSON.stringify(err)}`);
2536        expectFail();
2537        console.info(`${caseName} test end`);
2538        done();
2539      }
2540    });
2541
2542    /* *
2543     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_Send_0500
2544     * @tc.name  : testNetworkMgrSocketTCPSocketSend0500
2545     * @tc.desc  : Sending data through TCP Socket connection,Input parameter is undefined; callback
2546     * @tc.size  : MediumTest
2547     * @tc.type  : Function
2548     * @tc.level : level 2
2549     */
2550    it('testNetworkMgrSocketTCPSocketSend0500', 0, async (done: Function) => {
2551      let caseName: string = 'testNetworkMgrSocketTCPSocketSend0500';
2552      try {
2553        console.info(`${caseName} test start`);
2554        await sleep(500);
2555        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
2556        expect(tcp).assertInstanceOf('Object');
2557        let bindAddress: socket.NetAddress = {
2558          address: '127.0.0.1',
2559          port: 4037
2560        };
2561        await tcp.bind(bindAddress);
2562        let tcpConnectOptions: socket.TCPConnectOptions = {
2563          address: bindAddress
2564        };
2565        await tcp.connect(tcpConnectOptions);
2566        tcp.send(undefined, async (err: BusinessError) => {
2567          if (err) {
2568            console.info(`${caseName} fail err:${JSON.stringify(err)}`);
2569            expectTrue(err.code===401);
2570          } else {
2571            console.info(`${caseName} success`);
2572            expectFail()
2573          }
2574          await tcp.close();
2575          console.info(`${caseName} test end`);
2576          done();
2577        });
2578      } catch (err) {
2579        console.info(`${caseName}_catch fail err:${JSON.stringify(err)}`);
2580        expectFail();
2581        console.info(`${caseName} test end`);
2582        done();
2583      }
2584    });
2585
2586    /* *
2587     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_Send_0600
2588     * @tc.name  : testNetworkMgrSocketTCPSocketSend0600
2589     * @tc.desc  : Sending data through TCP Socket connection,Send data of arraybuffer type; callback
2590     * @tc.size  : MediumTest
2591     * @tc.type  : Function
2592     * @tc.level : level 2
2593     */
2594    it('testNetworkMgrSocketTCPSocketSend0600', 0, async (done: Function) => {
2595      let caseName: string = 'testNetworkMgrSocketTCPSocketSend0600';
2596      try {
2597        console.info(`${caseName} test start`);
2598        await sleep(500);
2599        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
2600        expect(tcp).assertInstanceOf('Object');
2601        let bindAddress: socket.NetAddress = {
2602          address: '127.0.0.1',
2603          port: 4038
2604        };
2605        await tcp.bind(bindAddress);
2606        let tcpConnectOptions: socket.TCPConnectOptions = {
2607          address: bindAddress,
2608        };
2609        await tcp.connect(tcpConnectOptions);
2610        let tcpSendOptions: socket.TCPSendOptions = {
2611          data: new ArrayBuffer(123)
2612        };
2613        tcp.send(tcpSendOptions, async (err: BusinessError) => {
2614          if (err) {
2615            console.info(`${caseName} fail err:${JSON.stringify(err)}`);
2616            expectFail();
2617          } else {
2618            console.info(`${caseName} success`);
2619            expectSuccess();
2620          }
2621          await tcp.close();
2622          console.info(`${caseName} test end`);
2623          done();
2624        });
2625      } catch (err) {
2626        console.info(`${caseName}_catch fail err:${JSON.stringify(err)}`);
2627        expectFail();
2628        console.info(`${caseName} test end`);
2629        done();
2630      }
2631    });
2632
2633    /* *
2634     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_Send_0700
2635     * @tc.name  : testNetworkMgrSocketTCPSocketSend0700
2636     * @tc.desc  : Sending data through TCP Socket connection,Set data format to empty string; callback
2637     * @tc.size  : MediumTest
2638     * @tc.type  : Function
2639     * @tc.level : level 2
2640     */
2641    it('testNetworkMgrSocketTCPSocketSend0700', 0, async (done: Function) => {
2642      let caseName: string = 'testNetworkMgrSocketTCPSocketSend0700';
2643      try {
2644        console.info(`${caseName} test start`);
2645        await sleep(500);
2646        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
2647        expect(tcp).assertInstanceOf('Object');
2648        let bindAddress: socket.NetAddress = {
2649          address: '127.0.0.1',
2650          port: 4039
2651        };
2652        await tcp.bind(bindAddress);
2653        let tcpConnectOptions: socket.TCPConnectOptions = {
2654          address: bindAddress,
2655        };
2656        await tcp.connect(tcpConnectOptions);
2657        let tcpSendOptions: socket.TCPSendOptions = {
2658          data: 'Hello, server!',
2659          encoding: ''
2660        };
2661        tcp.send(tcpSendOptions, async (err: BusinessError) => {
2662          if (err) {
2663            console.info(`${caseName} fail err:${JSON.stringify(err)}`);
2664            expectFail();
2665          } else {
2666            console.info(`${caseName} success`);
2667            expectSuccess();
2668          }
2669          await tcp.close();
2670          console.info(`${caseName} test end`);
2671          done();
2672        });
2673      } catch (err) {
2674        console.info(`${caseName}_catch fail err:${JSON.stringify(err)}`);
2675        expectFail();
2676        console.info(`${caseName} test end`);
2677        done();
2678      }
2679    });
2680
2681    /* *
2682     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_Send_0800
2683     * @tc.name  : testNetworkMgrSocketTCPSocketSend0800
2684     * @tc.desc  : Sending data through TCP Socket connection,Set data format to UTF-8; callback
2685     * @tc.size  : MediumTest
2686     * @tc.type  : Function
2687     * @tc.level : level 2
2688     */
2689    it('testNetworkMgrSocketTCPSocketSend0800', 0, async (done: Function) => {
2690      let caseName: string = 'testNetworkMgrSocketTCPSocketSend0800';
2691      try {
2692        console.info(`${caseName} test start`);
2693        await sleep(500);
2694        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
2695        expect(tcp).assertInstanceOf('Object');
2696        let bindAddress: socket.NetAddress = {
2697          address: '127.0.0.1',
2698          port: 4040
2699        };
2700        await tcp.bind(bindAddress);
2701        let tcpConnectOptions: socket.TCPConnectOptions = {
2702          address: bindAddress,
2703        };
2704        await tcp.connect(tcpConnectOptions);
2705        let tcpSendOptions: socket.TCPSendOptions = {
2706          data: 'Hello, server!',
2707          encoding: 'UTF-8'
2708        };
2709        tcp.send(tcpSendOptions, async (err: BusinessError) => {
2710          if (err) {
2711            console.info(`${caseName} fail err:${JSON.stringify(err)}`);
2712            expectFail();
2713          } else {
2714            console.info(`${caseName} success`);
2715            expectSuccess();
2716          }
2717          await tcp.close();
2718          console.info(`${caseName} test end`);
2719          done();
2720        });
2721      } catch (err) {
2722        console.info(`${caseName}_catch fail err:${JSON.stringify(err)}`);
2723        expectFail();
2724        console.info(`${caseName} test end`);
2725        done();
2726      }
2727    });
2728
2729    /* *
2730     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_Send_0900
2731     * @tc.name  : testNetworkMgrSocketTCPSocketSend0900
2732     * @tc.desc  : Sending data through TCP Socket connection,Set data format to UTF-16BE; callback
2733     * @tc.size  : MediumTest
2734     * @tc.type  : Function
2735     * @tc.level : level 2
2736     */
2737    it('testNetworkMgrSocketTCPSocketSend0900', 0, async (done: Function) => {
2738      let caseName: string = 'testNetworkMgrSocketTCPSocketSend0900';
2739      try {
2740        console.info(`${caseName} test start`);
2741        await sleep(500);
2742        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
2743        expect(tcp).assertInstanceOf('Object');
2744        let bindAddress: socket.NetAddress = {
2745          address: '127.0.0.1',
2746          port: 4041
2747        };
2748        await tcp.bind(bindAddress);
2749        let tcpConnectOptions: socket.TCPConnectOptions = {
2750          address: bindAddress,
2751        };
2752        await tcp.connect(tcpConnectOptions);
2753        let tcpSendOptions: socket.TCPSendOptions = {
2754          data: 'Hello, server!',
2755          encoding: 'UTF-16BE'
2756        };
2757        tcp.send(tcpSendOptions, async (err: BusinessError) => {
2758          if (err) {
2759            console.info(`${caseName} fail err:${JSON.stringify(err)}`);
2760            expectFail();
2761          } else {
2762            console.info(`${caseName} success`);
2763            expectSuccess();
2764          }
2765          await tcp.close();
2766          console.info(`${caseName} test end`);
2767          done();
2768        });
2769      } catch (err) {
2770        console.info(`${caseName}_catch fail err:${JSON.stringify(err)}`);
2771        expectFail();
2772        console.info(`${caseName} test end`);
2773        done();
2774      }
2775    });
2776
2777    /* *
2778     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_Send_1000
2779     * @tc.name  : testNetworkMgrSocketTCPSocketSend1000
2780     * @tc.desc  : Sending data through TCP Socket connection,Set data format to UTF-16LE; callback
2781     * @tc.size  : MediumTest
2782     * @tc.type  : Function
2783     * @tc.level : level 2
2784     */
2785    it('testNetworkMgrSocketTCPSocketSend1000', 0, async (done: Function) => {
2786      let caseName: string = 'testNetworkMgrSocketTCPSocketSend1000';
2787      try {
2788        console.info(`${caseName} test start`);
2789        await sleep(500);
2790        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
2791        expect(tcp).assertInstanceOf('Object');
2792        let bindAddress: socket.NetAddress = {
2793          address: '127.0.0.1',
2794          port: 4042
2795        };
2796        await tcp.bind(bindAddress);
2797        let tcpConnectOptions: socket.TCPConnectOptions = {
2798          address: bindAddress,
2799        };
2800        await tcp.connect(tcpConnectOptions);
2801        let tcpSendOptions: socket.TCPSendOptions = {
2802          data: 'Hello, server!',
2803          encoding: 'UTF-16LE'
2804        };
2805        tcp.send(tcpSendOptions, async (err: BusinessError) => {
2806          if (err) {
2807            console.info(`${caseName} fail err:${JSON.stringify(err)}`);
2808            expectFail();
2809          } else {
2810            console.info(`${caseName} success`);
2811            expectSuccess();
2812          }
2813          await tcp.close();
2814          console.info(`${caseName} test end`);
2815          done();
2816        });
2817      } catch (err) {
2818        console.info(`${caseName}_catch fail err:${JSON.stringify(err)}`);
2819        expectFail();
2820        console.info(`${caseName} test end`);
2821        done();
2822      }
2823    });
2824
2825    /* *
2826     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_Send_1100
2827     * @tc.name  : testNetworkMgrSocketTCPSocketSend1100
2828     * @tc.desc  : Sending data through TCP Socket connection,Set data format to UTF-16; callback
2829     * @tc.size  : MediumTest
2830     * @tc.type  : Function
2831     * @tc.level : level 2
2832     */
2833    it('testNetworkMgrSocketTCPSocketSend1100', 0, async (done: Function) => {
2834      let caseName: string = 'testNetworkMgrSocketTCPSocketSend1100';
2835      try {
2836        console.info(`${caseName} test start`);
2837        await sleep(500);
2838        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
2839        expect(tcp).assertInstanceOf('Object');
2840        let bindAddress: socket.NetAddress = {
2841          address: '127.0.0.1',
2842          port: 4043
2843        };
2844        await tcp.bind(bindAddress);
2845        let tcpConnectOptions: socket.TCPConnectOptions = {
2846          address: bindAddress,
2847        };
2848        await tcp.connect(tcpConnectOptions);
2849        let tcpSendOptions: socket.TCPSendOptions = {
2850          data: 'Hello, server!',
2851          encoding: 'UTF-16'
2852        };
2853        tcp.send(tcpSendOptions, async (err: BusinessError) => {
2854          if (err) {
2855            console.info(`${caseName} fail err:${JSON.stringify(err)}`);
2856            expectFail();
2857          } else {
2858            console.info(`${caseName} success`);
2859            expectSuccess();
2860          }
2861          await tcp.close();
2862          console.info(`${caseName} test end`);
2863          done();
2864        });
2865      } catch (err) {
2866        console.info(`${caseName}_catch fail err:${JSON.stringify(err)}`);
2867        expectFail();
2868        console.info(`${caseName} test end`);
2869        done();
2870      }
2871    });
2872
2873    /* *
2874     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_Send_1200
2875     * @tc.name  : testNetworkMgrSocketTCPSocketSend1200
2876     * @tc.desc  : Sending data through TCP Socket connection,Set data format to US-AECII; callback
2877     * @tc.size  : MediumTest
2878     * @tc.type  : Function
2879     * @tc.level : level 2
2880     */
2881    it('testNetworkMgrSocketTCPSocketSend1200', 0, async (done: Function) => {
2882      let caseName: string = 'testNetworkMgrSocketTCPSocketSend1200';
2883      try {
2884        console.info(`${caseName} test start`);
2885        await sleep(500);
2886        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
2887        expect(tcp).assertInstanceOf('Object');
2888        let bindAddress: socket.NetAddress = {
2889          address: '127.0.0.1',
2890          port: 4044
2891        };
2892        await tcp.bind(bindAddress);
2893        let tcpConnectOptions: socket.TCPConnectOptions = {
2894          address: bindAddress,
2895        };
2896        await tcp.connect(tcpConnectOptions);
2897        let tcpSendOptions: socket.TCPSendOptions = {
2898          data: 'Hello, server!',
2899          encoding: 'US-AECII'
2900        };
2901        tcp.send(tcpSendOptions, async (err: BusinessError) => {
2902          if (err) {
2903            console.info(`${caseName} fail err:${JSON.stringify(err)}`);
2904            expectFail();
2905          } else {
2906            console.info(`${caseName} success`);
2907            expectSuccess();
2908          }
2909          await tcp.close();
2910          console.info(`${caseName} test end`);
2911          done();
2912        });
2913      } catch (err) {
2914        console.info(`${caseName}_catch fail err:${JSON.stringify(err)}`);
2915        expectFail();
2916        console.info(`${caseName} test end`);
2917        done();
2918      }
2919    });
2920
2921    /* *
2922     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_Send_1300
2923     * @tc.name  : testNetworkMgrSocketTCPSocketSend1300
2924     * @tc.desc  : Sending data through TCP Socket connection,Set data format to ISO-8859-1; callback
2925     * @tc.size  : MediumTest
2926     * @tc.type  : Function
2927     * @tc.level : level 2
2928     */
2929    it('testNetworkMgrSocketTCPSocketSend1300', 0, async (done: Function) => {
2930      let caseName: string = 'testNetworkMgrSocketTCPSocketSend1300';
2931      try {
2932        console.info(`${caseName} test start`);
2933        await sleep(500);
2934        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
2935        expect(tcp).assertInstanceOf('Object');
2936        let bindAddress: socket.NetAddress = {
2937          address: '127.0.0.1',
2938          port: 4045
2939        };
2940        await tcp.bind(bindAddress);
2941        let tcpConnectOptions: socket.TCPConnectOptions = {
2942          address: bindAddress,
2943        };
2944        await tcp.connect(tcpConnectOptions);
2945        let tcpSendOptions: socket.TCPSendOptions = {
2946          data: 'Hello, server!',
2947          encoding: 'ISO-8859-1'
2948        };
2949        tcp.send(tcpSendOptions, async (err: BusinessError) => {
2950          if (err) {
2951            console.info(`${caseName} fail err:${JSON.stringify(err)}`);
2952            expectFail();
2953          } else {
2954            console.info(`${caseName} success`);
2955            expectSuccess();
2956          }
2957          await tcp.close();
2958          console.info(`${caseName} test end`);
2959          done();
2960        });
2961      } catch (err) {
2962        console.info(`${caseName}_catch fail err:${JSON.stringify(err)}`);
2963        expectFail();
2964        console.info(`${caseName} test end`);
2965        done();
2966      }
2967    });
2968
2969    /* *
2970     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_Send_1400
2971     * @tc.name  : testNetworkMgrSocketTCPSocketSend1400
2972     * @tc.desc  : Sending data through TCP Socket connection,Set data format to GB2312; callback
2973     * @tc.size  : MediumTest
2974     * @tc.type  : Function
2975     * @tc.level : level 2
2976     */
2977    it('testNetworkMgrSocketTCPSocketSend1400', 0, async (done: Function) => {
2978      let caseName: string = 'testNetworkMgrSocketTCPSocketSend1400';
2979      try {
2980        console.info(`${caseName} test start`);
2981        await sleep(500);
2982        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
2983        expect(tcp).assertInstanceOf('Object');
2984        let bindAddress: socket.NetAddress = {
2985          address: '127.0.0.1',
2986          port: 4046
2987        };
2988        await tcp.bind(bindAddress);
2989        let tcpConnectOptions: socket.TCPConnectOptions = {
2990          address: bindAddress,
2991        };
2992        await tcp.connect(tcpConnectOptions);
2993        let tcpSendOptions: socket.TCPSendOptions = {
2994          data: 'Hello, server!',
2995          encoding: 'GB2312'
2996        };
2997        tcp.send(tcpSendOptions, async (err: BusinessError) => {
2998          if (err) {
2999            console.info(`${caseName} fail err:${JSON.stringify(err)}`);
3000            expectFail();
3001          } else {
3002            console.info(`${caseName} success`);
3003            expectSuccess();
3004          }
3005          await tcp.close();
3006          console.info(`${caseName} test end`);
3007          done();
3008        });
3009      } catch (err) {
3010        console.info(`${caseName}_catch fail err:${JSON.stringify(err)}`);
3011        expectFail();
3012        console.info(`${caseName} test end`);
3013        done();
3014      }
3015    });
3016
3017    /* *
3018     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_Send_1500
3019     * @tc.name  : testNetworkMgrSocketTCPSocketSend1500
3020     * @tc.desc  : Sending data through TCP Socket connection,Set data format to undefined; callback
3021     * @tc.size  : MediumTest
3022     * @tc.type  : Function
3023     * @tc.level : level 2
3024     */
3025    it('testNetworkMgrSocketTCPSocketSend1500', 0, async (done: Function) => {
3026      let caseName: string = 'testNetworkMgrSocketTCPSocketSend1500';
3027      try {
3028        console.info(`${caseName} test start`);
3029        await sleep(500);
3030        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
3031        expect(tcp).assertInstanceOf('Object');
3032        let bindAddress: socket.NetAddress = {
3033          address: '127.0.0.1',
3034          port: 4047
3035        };
3036        await tcp.bind(bindAddress);
3037        let tcpConnectOptions: socket.TCPConnectOptions = {
3038          address: bindAddress
3039        };
3040        await tcp.connect(tcpConnectOptions);
3041        let tcpSendOptions: socket.TCPSendOptions = {
3042          data: 'Hello, server!',
3043          encoding: undefined
3044        };
3045        tcp.send(tcpSendOptions, async (err: BusinessError) => {
3046          if (err) {
3047            console.info(`${caseName} fail err:${JSON.stringify(err)}`);
3048            expectFail();
3049          } else {
3050            console.info(`${caseName} success`);
3051            expectSuccess();
3052          }
3053          await tcp.close();
3054          console.info(`${caseName} test end`);
3055          done();
3056        });
3057      } catch (err) {
3058        console.info(`${caseName}_catch fail err:${JSON.stringify(err)}`);
3059        expectFail();
3060        console.info(`${caseName} test end`);
3061        done();
3062      }
3063    });
3064
3065    /* *
3066     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_Send_1600
3067     * @tc.name  : testNetworkMgrSocketTCPSocketSend1600
3068     * @tc.desc  : Sending data through TCP Socket connection,To the client; promise
3069     * @tc.size  : MediumTest
3070     * @tc.type  : Function
3071     * @tc.level : level 2
3072     */
3073    it('testNetworkMgrSocketTCPSocketSend1600', 0, async (done: Function) => {
3074      let caseName: string = 'testNetworkMgrSocketTCPSocketSend1600';
3075      try {
3076        console.info(`${caseName} test start`);
3077        await sleep(500);
3078        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
3079        expect(tcp).assertInstanceOf('Object');
3080        let bindAddress: socket.NetAddress = {
3081          address: '127.0.0.1',
3082          port: 4049
3083        };
3084        await tcp.bind(bindAddress);
3085        let tcpConnectOptions: socket.TCPConnectOptions = {
3086          address:bindAddress
3087        };
3088        await tcp.connect(tcpConnectOptions);
3089        let tcpSendOptions: socket.TCPSendOptions = {
3090          data: 'Hello, server!'
3091        };
3092        tcp.send(tcpSendOptions).then(() => {
3093          console.info(`${caseName} success`);
3094          expectSuccess();
3095          done();
3096        }).catch((err: BusinessError) => {
3097          console.info(`${caseName} fail err:${JSON.stringify(err)}`);
3098          expectFail();
3099          done();
3100        }).finally(async () => {
3101          await tcp.close();
3102          console.info(`${caseName} test end`);
3103          done();
3104        });
3105      } catch (err) {
3106        console.info(`${caseName}_catch fail err:${JSON.stringify(err)}`);
3107        expectFail();
3108        console.info(`${caseName} test end`);
3109        done();
3110      }
3111    });
3112
3113    /* *
3114     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_Send_1700
3115     * @tc.name  : testNetworkMgrSocketTCPSocketSend1700
3116     * @tc.desc  : Sending data through TCP Socket connection,To the server; promise
3117     * @tc.size  : MediumTest
3118     * @tc.type  : Function
3119     * @tc.level : level 2
3120     */
3121    it('testNetworkMgrSocketTCPSocketSend1700', 0, async (done: Function) => {
3122      let caseName: string = 'testNetworkMgrSocketTCPSocketSend1700';
3123      try {
3124        console.info(`${caseName} test start`);
3125        await sleep(500);
3126        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
3127        expect(tcp).assertInstanceOf('Object');
3128        let tcpServer: socket.TCPSocketServer = socket.constructTCPSocketServerInstance();
3129        let listenAddress: socket.NetAddress = {
3130          address: '127.0.0.1',
3131          port: 4048
3132        };
3133        await tcpServer.listen(listenAddress);
3134        let tcpConnectOptions: socket.TCPConnectOptions = {
3135          address:listenAddress
3136        };
3137        await tcp.connect(tcpConnectOptions);
3138        let tcpSendOptions: socket.TCPSendOptions = {
3139          data: 'Hello, server!'
3140        };
3141        tcp.send(tcpSendOptions).then(() => {
3142          console.info(`${caseName} success`);
3143          expectSuccess();
3144          done();
3145        }).catch((err: BusinessError) => {
3146          console.info(`${caseName} fail err:${JSON.stringify(err)}`);
3147          expectFail();
3148          done();
3149        }).finally(async () => {
3150          await tcp.close();
3151          console.info(`${caseName} test end`);
3152          done();
3153        });
3154      } catch (err) {
3155        console.info(`${caseName}_catch fail err:${JSON.stringify(err)}`);
3156        expectFail();
3157        console.info(`${caseName} test end`);
3158        done();
3159      }
3160    });
3161
3162    /* *
3163     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_Send_1900
3164     * @tc.name  : testNetworkMgrSocketTCPSocketSend1900
3165     * @tc.desc  : Sending data through TCP Socket connection,Input parameter is null; promise
3166     * @tc.size  : MediumTest
3167     * @tc.type  : Function
3168     * @tc.level : level 2
3169     */
3170    it('testNetworkMgrSocketTCPSocketSend1900', 0, async (done: Function) => {
3171      let caseName: string = 'testNetworkMgrSocketTCPSocketSend1900';
3172      try {
3173        console.info(`${caseName} test start`);
3174        await sleep(500);
3175        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
3176        expect(tcp).assertInstanceOf('Object');
3177        let tcpServer: socket.TCPSocketServer = socket.constructTCPSocketServerInstance();
3178        let listenAddress: socket.NetAddress = {
3179          address: '127.0.0.1',
3180          port: 4050
3181        };
3182        await tcpServer.listen(listenAddress);
3183        let tcpConnectOptions: socket.TCPConnectOptions = {
3184          address:listenAddress
3185        };
3186        await tcp.connect(tcpConnectOptions);
3187        tcp.send(null).then(() => {
3188          console.info(`${caseName} success`);
3189          expectFail();
3190          done();
3191        }).catch((err: BusinessError) => {
3192          console.info(`${caseName} fail err:${JSON.stringify(err)}`);
3193          expectTrue(err.code===401);
3194          done();
3195        }).finally(async () => {
3196          await tcp.close();
3197          console.info(`${caseName} test end`);
3198          done();
3199        });
3200      } catch (err) {
3201        console.info(`${caseName}_catch fail err:${JSON.stringify(err)}`);
3202        expectFail();
3203        console.info(`${caseName} test end`);
3204        done();
3205      }
3206    });
3207
3208    /* *
3209     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_Send_2000
3210     * @tc.name  : testNetworkMgrSocketTCPSocketSend2000
3211     * @tc.desc  : Sending data through TCP Socket connection,Input parameter is undefined; promise
3212     * @tc.size  : MediumTest
3213     * @tc.type  : Function
3214     * @tc.level : level 2
3215     */
3216    it('testNetworkMgrSocketTCPSocketSend2000', 0, async (done: Function) => {
3217      let caseName: string = 'testNetworkMgrSocketTCPSocketSend2000';
3218      try {
3219        console.info(`${caseName} test start`);
3220        await sleep(500);
3221        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
3222        expect(tcp).assertInstanceOf('Object');
3223        let tcpServer: socket.TCPSocketServer = socket.constructTCPSocketServerInstance();
3224        let listenAddress: socket.NetAddress = {
3225          address: '127.0.0.1',
3226          port: 4051
3227        };
3228        await tcpServer.listen(listenAddress);
3229        let tcpConnectOptions: socket.TCPConnectOptions = {
3230          address:listenAddress
3231        };
3232        await tcp.connect(tcpConnectOptions);
3233        tcp.send(undefined).then(() => {
3234          console.info(`${caseName} success`);
3235          expectFail();
3236          done();
3237        }).catch((err: BusinessError) => {
3238          console.info(`${caseName} fail err:${JSON.stringify(err)}`);
3239          expectTrue(err.code===401);
3240          done();
3241        }).finally(async () => {
3242          await tcp.close();
3243          console.info(`${caseName} test end`);
3244          done();
3245        });
3246      } catch (err) {
3247        console.info(`${caseName}_catch fail err:${JSON.stringify(err)}`);
3248        expectFail();
3249        console.info(`${caseName} test end`);
3250        done();
3251      }
3252    });
3253
3254    /* *
3255     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_Send_2100
3256     * @tc.name  : testNetworkMgrSocketTCPSocketSend2100
3257     * @tc.desc  : Sending data through TCP Socket connection,Send data of arraybuffer type; promise
3258     * @tc.size  : MediumTest
3259     * @tc.type  : Function
3260     * @tc.level : level 2
3261     */
3262    it('testNetworkMgrSocketTCPSocketSend2100', 0, async (done: Function) => {
3263      let caseName: string = 'testNetworkMgrSocketTCPSocketSend2100';
3264      try {
3265        console.info(`${caseName} test start`);
3266        await sleep(500);
3267        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
3268        expect(tcp).assertInstanceOf('Object');
3269        let bindAddress: socket.NetAddress = {
3270          address: '127.0.0.1',
3271          port: 4052
3272        };
3273        await tcp.bind(bindAddress);
3274        let tcpConnectOptions: socket.TCPConnectOptions = {
3275          address:bindAddress
3276        };
3277        await tcp.connect(tcpConnectOptions);
3278        let tcpSendOptions: socket.TCPSendOptions = {
3279          data: new ArrayBuffer(123)
3280        };
3281        tcp.send(tcpSendOptions).then(() => {
3282          console.info(`${caseName} success`);
3283          expectSuccess();
3284          done();
3285        }).catch((err: BusinessError) => {
3286          console.info(`${caseName} fail err:${JSON.stringify(err)}`);
3287          expectFail();
3288          done();
3289        }).finally(async () => {
3290          await tcp.close();
3291          console.info(`${caseName} test end`);
3292          done();
3293        });
3294      } catch (err) {
3295        console.info(`${caseName}_catch fail err:${JSON.stringify(err)}`);
3296        expectFail();
3297        console.info(`${caseName} test end`);
3298        done();
3299      }
3300    });
3301
3302    /* *
3303     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_Send_2200
3304     * @tc.name  : testNetworkMgrSocketTCPSocketSend2200
3305     * @tc.desc  : Sending data through TCP Socket connection,Set data format to empty string; promise
3306     * @tc.size  : MediumTest
3307     * @tc.type  : Function
3308     * @tc.level : level 2
3309     */
3310    it('testNetworkMgrSocketTCPSocketSend2200', 0, async (done: Function) => {
3311      let caseName: string = 'testNetworkMgrSocketTCPSocketSend2200';
3312      try {
3313        console.info(`${caseName} test start`);
3314        await sleep(500);
3315        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
3316        expect(tcp).assertInstanceOf('Object');
3317        let bindAddress: socket.NetAddress = {
3318          address: '127.0.0.1',
3319          port: 4053
3320        };
3321        await tcp.bind(bindAddress);
3322        let tcpConnectOptions: socket.TCPConnectOptions = {
3323          address:bindAddress
3324        };
3325        await tcp.connect(tcpConnectOptions);
3326        let tcpSendOptions: socket.TCPSendOptions = {
3327          data: 'Hello, server!',
3328          encoding: ''
3329        };
3330        tcp.send(tcpSendOptions).then(() => {
3331          console.info(`${caseName} success`);
3332          expectSuccess();
3333          done();
3334        }).catch((err: BusinessError) => {
3335          console.info(`${caseName} fail err:${JSON.stringify(err)}`);
3336          expectFail();
3337          done();
3338        }).finally(async () => {
3339          await tcp.close();
3340          console.info(`${caseName} test end`);
3341          done();
3342        });
3343      } catch (err) {
3344        console.info(`${caseName}_catch fail err:${JSON.stringify(err)}`);
3345        expectFail();
3346        console.info(`${caseName} test end`);
3347        done();
3348      }
3349    });
3350
3351    /* *
3352     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_Send_2300
3353     * @tc.name  : testNetworkMgrSocketTCPSocketSend2300
3354     * @tc.desc  : Sending data through TCP Socket connection,Set data format to UTF-8; promise
3355     * @tc.size  : MediumTest
3356     * @tc.type  : Function
3357     * @tc.level : level 2
3358     */
3359    it('testNetworkMgrSocketTCPSocketSend2300', 0, async (done: Function) => {
3360      let caseName: string = 'testNetworkMgrSocketTCPSocketSend2300';
3361      try {
3362        console.info(`${caseName} test start`);
3363        await sleep(500);
3364        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
3365        expect(tcp).assertInstanceOf('Object');
3366        let bindAddress: socket.NetAddress = {
3367          address: '127.0.0.1',
3368          port: 4054
3369        };
3370        await tcp.bind(bindAddress);
3371        let tcpConnectOptions: socket.TCPConnectOptions = {
3372          address: bindAddress
3373        };
3374        await tcp.connect(tcpConnectOptions);
3375        let tcpSendOptions: socket.TCPSendOptions = {
3376          data: 'Hello, server!',
3377          encoding: 'UTF-8'
3378        };
3379        tcp.send(tcpSendOptions).then(() => {
3380          console.info(`${caseName} success`);
3381          expectSuccess();
3382          done();
3383        }).catch((err: BusinessError) => {
3384          console.info(`${caseName} fail err:${JSON.stringify(err)}`);
3385          expectFail();
3386          done();
3387        }).finally(async () => {
3388          await tcp.close();
3389          console.info(`${caseName} test end`);
3390          done();
3391        });
3392      } catch (err) {
3393        console.info(`${caseName}_catch fail err:${JSON.stringify(err)}`);
3394        expectFail();
3395        console.info(`${caseName} test end`);
3396        done();
3397      }
3398    });
3399
3400    /* *
3401     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_Send_2400
3402     * @tc.name  : testNetworkMgrSocketTCPSocketSend2400
3403     * @tc.desc  : Sending data through TCP Socket connection,Set data format to UTF-16BE; promise
3404     * @tc.size  : MediumTest
3405     * @tc.type  : Function
3406     * @tc.level : level 2
3407     */
3408    it('testNetworkMgrSocketTCPSocketSend2400', 0, async (done: Function) => {
3409      let caseName: string = 'testNetworkMgrSocketTCPSocketSend2400';
3410      try {
3411        console.info(`${caseName} test start`);
3412        await sleep(500);
3413        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
3414        expect(tcp).assertInstanceOf('Object');
3415        let bindAddress: socket.NetAddress = {
3416          address: '127.0.0.1',
3417          port: 4055
3418        };
3419        await tcp.bind(bindAddress);
3420        let tcpConnectOptions: socket.TCPConnectOptions = {
3421          address:bindAddress
3422        };
3423        await tcp.connect(tcpConnectOptions);
3424        let tcpSendOptions: socket.TCPSendOptions = {
3425          data: 'Hello, server!',
3426          encoding: 'UTF-16BE'
3427        };
3428        tcp.send(tcpSendOptions).then(() => {
3429          console.info(`${caseName} success`);
3430          expectSuccess();
3431          done();
3432        }).catch((err: BusinessError) => {
3433          console.info(`${caseName} fail err:${JSON.stringify(err)}`);
3434          expectFail();
3435          done();
3436        }).finally(async () => {
3437          await tcp.close();
3438          console.info(`${caseName} test end`);
3439          done();
3440        });
3441      } catch (err) {
3442        console.info(`${caseName}_catch fail err:${JSON.stringify(err)}`);
3443        expectFail();
3444        console.info(`${caseName} test end`);
3445        done();
3446      }
3447    });
3448
3449    /* *
3450     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_Send_2500
3451     * @tc.name  : testNetworkMgrSocketTCPSocketSend2500
3452     * @tc.desc  : Sending data through TCP Socket connection,Set data format to UTF-16LE; promise
3453     * @tc.size  : MediumTest
3454     * @tc.type  : Function
3455     * @tc.level : level 2
3456     */
3457    it('testNetworkMgrSocketTCPSocketSend2500', 0, async (done: Function) => {
3458      let caseName: string = 'testNetworkMgrSocketTCPSocketSend2500';
3459      try {
3460        console.info(`${caseName} test start`);
3461        await sleep(500);
3462        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
3463        expect(tcp).assertInstanceOf('Object');
3464        let bindAddress: socket.NetAddress = {
3465          address: '127.0.0.1',
3466          port: 4056
3467        };
3468        await tcp.bind(bindAddress);
3469        let tcpConnectOptions: socket.TCPConnectOptions = {
3470          address: bindAddress
3471        };
3472        await tcp.connect(tcpConnectOptions);
3473        let tcpSendOptions: socket.TCPSendOptions = {
3474          data: 'Hello, server!',
3475          encoding: 'UTF-16LE'
3476        };
3477        tcp.send(tcpSendOptions).then(() => {
3478          console.info(`${caseName} success`);
3479          expectSuccess();
3480          done();
3481        }).catch((err: BusinessError) => {
3482          console.info(`${caseName} fail err:${JSON.stringify(err)}`);
3483          expectFail();
3484          done();
3485        }).finally(async () => {
3486          await tcp.close();
3487          console.info(`${caseName} test end`);
3488          done();
3489        });
3490      } catch (err) {
3491        console.info(`${caseName}_catch fail err:${JSON.stringify(err)}`);
3492        expectFail();
3493        console.info(`${caseName} test end`);
3494        done();
3495      }
3496    });
3497
3498    /* *
3499     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_Send_2600
3500     * @tc.name  : testNetworkMgrSocketTCPSocketSend2600
3501     * @tc.desc  : Sending data through TCP Socket connection,Set data format to UTF-16; promise
3502     * @tc.size  : MediumTest
3503     * @tc.type  : Function
3504     * @tc.level : level 2
3505     */
3506    it('testNetworkMgrSocketTCPSocketSend2600', 0, async (done: Function) => {
3507      let caseName: string = 'testNetworkMgrSocketTCPSocketSend2600';
3508      try {
3509        console.info(`${caseName} test start`);
3510        await sleep(500);
3511        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
3512        expect(tcp).assertInstanceOf('Object');
3513        let bindAddress: socket.NetAddress = {
3514          address: '127.0.0.1',
3515          port: 4057
3516        };
3517        await tcp.bind(bindAddress);
3518        let tcpConnectOptions: socket.TCPConnectOptions = {
3519          address: bindAddress
3520        };
3521        await tcp.connect(tcpConnectOptions);
3522        let tcpSendOptions: socket.TCPSendOptions = {
3523          data: 'Hello, server!',
3524          encoding: 'UTF-16'
3525        };
3526        tcp.send(tcpSendOptions).then(() => {
3527          console.info(`${caseName} success`);
3528          expectSuccess();
3529          done();
3530        }).catch((err: BusinessError) => {
3531          console.info(`${caseName} fail err:${JSON.stringify(err)}`);
3532          expectFail();
3533          done();
3534        }).finally(async () => {
3535          await tcp.close();
3536          console.info(`${caseName} test end`);
3537          done();
3538        });
3539      } catch (err) {
3540        console.info(`${caseName}_catch fail err:${JSON.stringify(err)}`);
3541        expectFail();
3542        console.info(`${caseName} test end`);
3543        done();
3544      }
3545    });
3546
3547    /* *
3548     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_Send_2700
3549     * @tc.name  : testNetworkMgrSocketTCPSocketSend2700
3550     * @tc.desc  : Sending data through TCP Socket connection,Set data format to US-AECII; promise
3551     * @tc.size  : MediumTest
3552     * @tc.type  : Function
3553     * @tc.level : level 2
3554     */
3555    it('testNetworkMgrSocketTCPSocketSend2700', 0, async (done: Function) => {
3556      let caseName: string = 'testNetworkMgrSocketTCPSocketSend2700';
3557      try {
3558        console.info(`${caseName} test start`);
3559        await sleep(500);
3560        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
3561        expect(tcp).assertInstanceOf('Object');
3562        let bindAddress: socket.NetAddress = {
3563          address: '127.0.0.1',
3564          port: 4058
3565        };
3566        await tcp.bind(bindAddress);
3567        let tcpConnectOptions: socket.TCPConnectOptions = {
3568          address:bindAddress
3569        };
3570        await tcp.connect(tcpConnectOptions);
3571        let tcpSendOptions: socket.TCPSendOptions = {
3572          data: 'Hello, server!',
3573          encoding: 'US-AECII'
3574        };
3575        tcp.send(tcpSendOptions).then(() => {
3576          console.info(`${caseName} success`);
3577          expectSuccess();
3578          done();
3579        }).catch((err: BusinessError) => {
3580          console.info(`${caseName} fail err:${JSON.stringify(err)}`);
3581          expectFail();
3582          done();
3583        }).finally(async () => {
3584          await tcp.close();
3585          console.info(`${caseName} test end`);
3586          done();
3587        });
3588      } catch (err) {
3589        console.info(`${caseName}_catch fail err:${JSON.stringify(err)}`);
3590        expectFail();
3591        console.info(`${caseName} test end`);
3592        done();
3593      }
3594    });
3595
3596    /* *
3597     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_Send_2800
3598     * @tc.name  : testNetworkMgrSocketTCPSocketSend2800
3599     * @tc.desc  : Sending data through TCP Socket connection,Set data format to ISO-8859-1; promise
3600     * @tc.size  : MediumTest
3601     * @tc.type  : Function
3602     * @tc.level : level 2
3603     */
3604    it('testNetworkMgrSocketTCPSocketSend2800', 0, async (done: Function) => {
3605      let caseName: string = 'testNetworkMgrSocketTCPSocketSend2800';
3606      try {
3607        console.info(`${caseName} test start`);
3608        await sleep(500);
3609        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
3610        expect(tcp).assertInstanceOf('Object');
3611        let bindAddress: socket.NetAddress = {
3612          address: '127.0.0.1',
3613          port: 4059
3614        };
3615        await tcp.bind(bindAddress);
3616        let tcpConnectOptions: socket.TCPConnectOptions = {
3617          address: bindAddress
3618        };
3619        await tcp.connect(tcpConnectOptions);
3620        let tcpSendOptions: socket.TCPSendOptions = {
3621          data: 'Hello, server!',
3622          encoding: 'ISO-8859-1'
3623        };
3624        tcp.send(tcpSendOptions).then(() => {
3625          console.info(`${caseName} success`);
3626          expectSuccess();
3627          done();
3628        }).catch((err: BusinessError) => {
3629          console.info(`${caseName} fail err:${JSON.stringify(err)}`);
3630          expectFail();
3631          done();
3632        }).finally(async () => {
3633          await tcp.close();
3634          console.info(`${caseName} test end`);
3635          done();
3636        });
3637      } catch (err) {
3638        console.info(`${caseName}_catch fail err:${JSON.stringify(err)}`);
3639        expectFail();
3640        console.info(`${caseName} test end`);
3641        done();
3642      }
3643    });
3644
3645    /* *
3646     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_Send_2900
3647     * @tc.name  : testNetworkMgrSocketTCPSocketSend2900
3648     * @tc.desc  : Sending data through TCP Socket connection,Set data format to GB2312; promise
3649     * @tc.size  : MediumTest
3650     * @tc.type  : Function
3651     * @tc.level : level 2
3652     */
3653    it('testNetworkMgrSocketTCPSocketSend2900', 0, async (done: Function) => {
3654      let caseName: string = 'testNetworkMgrSocketTCPSocketSend2900';
3655      try {
3656        console.info(`${caseName} test start`);
3657        await sleep(500);
3658        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
3659        expect(tcp).assertInstanceOf('Object');
3660        let bindAddress: socket.NetAddress = {
3661          address: '127.0.0.1',
3662          port: 4060
3663        };
3664        await tcp.bind(bindAddress);
3665        let tcpConnectOptions: socket.TCPConnectOptions = {
3666          address:bindAddress
3667        };
3668        await tcp.connect(tcpConnectOptions);
3669        let tcpSendOptions: socket.TCPSendOptions = {
3670          data: 'Hello, server!',
3671          encoding: 'GB2312'
3672        };
3673        tcp.send(tcpSendOptions).then(() => {
3674          console.info(`${caseName} success`);
3675          expectSuccess();
3676          done();
3677        }).catch((err: BusinessError) => {
3678          console.info(`${caseName} fail err:${JSON.stringify(err)}`);
3679          expectFail();
3680          done();
3681        }).finally(async () => {
3682          await tcp.close();
3683          console.info(`${caseName} test end`);
3684          done();
3685        });
3686      } catch (err) {
3687        console.info(`${caseName}_catch fail err:${JSON.stringify(err)}`);
3688        expectFail();
3689        console.info(`${caseName} test end`);
3690        done();
3691      }
3692    });
3693
3694    /* *
3695     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_Send_3000
3696     * @tc.name  : testNetworkMgrSocketTCPSocketSend3000
3697     * @tc.desc  : Sending data through TCP Socket connection,Set data format to undefined; promise
3698     * @tc.size  : MediumTest
3699     * @tc.type  : Function
3700     * @tc.level : level 2
3701     */
3702    it('testNetworkMgrSocketTCPSocketSend3000', 0, async (done: Function) => {
3703      let caseName: string = 'testNetworkMgrSocketTCPSocketSend3000';
3704      try {
3705        console.info(`${caseName} test start`);
3706        await sleep(500);
3707        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
3708        expect(tcp).assertInstanceOf('Object');
3709        let bindAddress: socket.NetAddress = {
3710          address: '127.0.0.1',
3711          port: 4061
3712        };
3713        await tcp.bind(bindAddress);
3714        let tcpConnectOptions: socket.TCPConnectOptions = {
3715          address:bindAddress
3716        };
3717        await tcp.connect(tcpConnectOptions);
3718        let tcpSendOptions: socket.TCPSendOptions = {
3719          data: 'Hello, server!',
3720          encoding: undefined
3721        };
3722        tcp.send(tcpSendOptions).then(() => {
3723          console.info(`${caseName} success`);
3724          expectSuccess();
3725          done();
3726        }).catch((err: BusinessError) => {
3727          console.info(`${caseName} fail err:${JSON.stringify(err)}`);
3728          expectFail();
3729          done();
3730        }).finally(async () => {
3731          await tcp.close();
3732          console.info(`${caseName} test end`);
3733          done();
3734        });
3735      } catch (err) {
3736        console.info(`${caseName}_catch fail err:${JSON.stringify(err)}`);
3737        expectFail();
3738        console.info(`${caseName} test end`);
3739        done();
3740      }
3741    });
3742
3743    /* *
3744     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_Close_0100
3745     * @tc.name  : testNetworkMgrSocketTCPSocketClose0100
3746     * @tc.desc  : Close the TCP Socket connection,Call close before binding or listening; callback
3747     * @tc.size  : MediumTest
3748     * @tc.type  : Function
3749     * @tc.level : level 2
3750     */
3751    it('testNetworkMgrSocketTCPSocketClose0100', 0, async (done: Function) => {
3752      let caseName: string = 'testNetworkMgrSocketTCPSocketClose0100';
3753      try {
3754        console.info(`${caseName} test start`);
3755        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
3756        expect(tcp).assertInstanceOf('Object');
3757        tcp.close((err: BusinessError) => {
3758          if (err) {
3759            console.info(`${caseName} fail err:${JSON.stringify(err)}`);
3760            expectTrue(err.code===2300999);
3761          } else {
3762            console.info(`${caseName} success`);
3763            expectFail();
3764          }
3765          console.info(`${caseName} test end`);
3766          done();
3767        });
3768      } catch (err) {
3769        console.info(`${caseName}_catch fail err:${JSON.stringify(err)}`);
3770        expectFail();
3771        console.info(`${caseName} test end`);
3772        done();
3773      }
3774    });
3775
3776    /* *
3777     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_Close_0200
3778     * @tc.name  : testNetworkMgrSocketTCPSocketClose0200
3779     * @tc.desc  : Close the TCP Socket connection,After bind and connect; callback
3780     * @tc.size  : MediumTest
3781     * @tc.type  : Function
3782     * @tc.level : level 2
3783     */
3784    it('testNetworkMgrSocketTCPSocketClose0200', 0, async (done: Function) => {
3785      let caseName: string = 'testNetworkMgrSocketTCPSocketClose0200';
3786      try {
3787        console.info(`${caseName} test start`);
3788        await sleep(500);
3789        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
3790        expect(tcp).assertInstanceOf('Object');
3791        let bindAddress: socket.NetAddress = {
3792          address: '127.0.0.1',
3793          port: 4062
3794        };
3795        await tcp.bind(bindAddress);
3796        let tcpConnectOptions: socket.TCPConnectOptions = {
3797          address: bindAddress,
3798        };
3799        await tcp.connect(tcpConnectOptions);
3800        tcp.close((err: BusinessError) => {
3801          if (err) {
3802            console.info(`${caseName} fail err:${JSON.stringify(err)}`);
3803            expectFail();
3804          } else {
3805            console.info(`${caseName} success`);
3806            expectSuccess();
3807          }
3808          console.info(`${caseName} test end`);
3809          done();
3810        });
3811      } catch (err) {
3812        console.info(`${caseName}_catch fail err:${JSON.stringify(err)}`);
3813        expectFail();
3814        console.info(`${caseName} test end`);
3815        done();
3816      }
3817    });
3818
3819    /* *
3820     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_Close_0300
3821     * @tc.name  : testNetworkMgrSocketTCPSocketClose0300
3822     * @tc.desc  : Close the TCP Socket connection ,after listen and connect; callback
3823     * @tc.size  : MediumTest
3824     * @tc.type  : Function
3825     * @tc.level : level 2
3826     */
3827    it('testNetworkMgrSocketTCPSocketClose0300', 0, async (done: Function) => {
3828      let caseName: string = 'testNetworkMgrSocketTCPSocketClose0300';
3829      try {
3830        console.info(`${caseName} test start`);
3831        await sleep(500);
3832        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
3833        expect(tcp).assertInstanceOf('Object');
3834        let tcpServer: socket.TCPSocketServer = socket.constructTCPSocketServerInstance();
3835        expect(tcpServer).assertInstanceOf('Object');
3836        let listenAddress: socket.NetAddress = {
3837          address: '127.0.0.1',
3838          port: 4063,
3839          family: 1
3840        };
3841        await tcpServer.listen(listenAddress);
3842        let tcpConnectOptions: socket.TCPConnectOptions = {
3843          address: listenAddress,
3844        };
3845        await tcp.connect(tcpConnectOptions);
3846        tcp.close((err: BusinessError) => {
3847          if (err) {
3848            console.info(`${caseName} fail err:${JSON.stringify(err)}`);
3849            expectFail();
3850          } else {
3851            console.info(`${caseName} success`);
3852            expectSuccess();
3853          }
3854          console.info(`${caseName} test end`);
3855          done();
3856        });
3857      } catch (err) {
3858        console.info(`${caseName}_catch fail err:${JSON.stringify(err)}`);
3859        expectFail();
3860        console.info(`${caseName} test end`);
3861        done();
3862      }
3863    });
3864
3865    /* *
3866     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_Close_0400
3867     * @tc.name  : testNetworkMgrSocketTCPSocketClose0400
3868     * @tc.desc  : Close the TCP Socket connection,Call close before binding or listening; promise
3869     * @tc.size  : MediumTest
3870     * @tc.type  : Function
3871     * @tc.level : level 2
3872     */
3873    it('testNetworkMgrSocketTCPSocketClose0400', 0, async (done: Function) => {
3874      let caseName: string = 'testNetworkMgrSocketTCPSocketClose0400';
3875      console.info(`${caseName} test start`);
3876      try {
3877        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
3878        expect(tcp).assertInstanceOf('Object');
3879        tcp.close().then(() => {
3880          console.info(`${caseName} success`);
3881          expectFail();
3882          done();
3883        }).catch((err: BusinessError) => {
3884          console.info(`${caseName} fail err:${JSON.stringify(err)}`);
3885          expectTrue(err.code===2300999);
3886          done();
3887        }).finally(() => {
3888          console.info(`${caseName} test end`);
3889          done();
3890        });
3891      } catch (err) {
3892        console.info(`${caseName}_catch fail err:${JSON.stringify(err)}`);
3893        expectFail();
3894        console.info(`${caseName} test end`);
3895        done();
3896      }
3897    });
3898
3899    /* *
3900     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_Close_0500
3901     * @tc.name  : testNetworkMgrSocketTCPSocketClose0500
3902     * @tc.desc  : Close the TCP Socket connection,after bind and connect; promise
3903     * @tc.size  : MediumTest
3904     * @tc.type  : Function
3905     * @tc.level : level 2
3906     */
3907    it('testNetworkMgrSocketTCPSocketClose0500', 0, async (done: Function) => {
3908      let caseName: string = 'testNetworkMgrSocketTCPSocketClose0500';
3909      console.info(`${caseName} test start`);
3910      await sleep(500);
3911      try {
3912        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
3913        expect(tcp).assertInstanceOf('Object');
3914        let bindAddress: socket.NetAddress = {
3915          address: '127.0.0.1',
3916          port: 4064
3917        };
3918        await tcp.bind(bindAddress);
3919        let tcpConnectOptions: socket.TCPConnectOptions = {
3920          address: bindAddress,
3921        };
3922        await tcp.connect(tcpConnectOptions);
3923        tcp.close().then(() => {
3924          console.info(`${caseName} success`);
3925          expectSuccess();
3926          done();
3927        }).catch((err: BusinessError) => {
3928          console.info(`${caseName} fail err:${JSON.stringify(err)}`);
3929          expectFail();
3930          done();
3931        }).finally(() => {
3932          console.info(`${caseName} test end`);
3933          done();
3934        });
3935      } catch (err) {
3936        console.info(`${caseName}_catch fail err:${JSON.stringify(err)}`);
3937        expectFail();
3938        console.info(`${caseName} test end`);
3939        done();
3940      }
3941    });
3942
3943    /* *
3944     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_Close_0600
3945     * @tc.name  : testNetworkMgrSocketTCPSocketClose0600
3946     * @tc.desc  : Close the TCP Socket connection,after listen and connect; promise
3947     * @tc.size  : MediumTest
3948     * @tc.type  : Function
3949     * @tc.level : level 2
3950     */
3951    it('testNetworkMgrSocketTCPSocketClose0600', 0, async (done: Function) => {
3952      let caseName: string = 'testNetworkMgrSocketTCPSocketClose0500';
3953      console.info(`${caseName} test start`);
3954      await sleep(500);
3955      try {
3956        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
3957        expect(tcp).assertInstanceOf('Object');
3958        let tcpServer: socket.TCPSocketServer = socket.constructTCPSocketServerInstance();
3959        expect(tcpServer).assertInstanceOf('Object');
3960        let listenAddress: socket.NetAddress = {
3961          address: '127.0.0.1',
3962          port: 4065,
3963          family: 1
3964        };
3965        await tcpServer.listen(listenAddress);
3966        let tcpConnectOptions: socket.TCPConnectOptions = {
3967          address: listenAddress,
3968        };
3969        await tcp.connect(tcpConnectOptions);
3970        tcp.close().then(() => {
3971          console.info(`${caseName} success`);
3972          expectSuccess();
3973          done();
3974        }).catch((err: BusinessError) => {
3975          console.info(`${caseName} fail err:${JSON.stringify(err)}`);
3976          expectFail();
3977          done();
3978        }).finally(() => {
3979          console.info(`${caseName} test end`);
3980          done();
3981        });
3982      } catch (err) {
3983        console.info(`${caseName}_catch fail err:${JSON.stringify(err)}`);
3984        expectFail();
3985        console.info(`${caseName} test end`);
3986        done();
3987      }
3988    });
3989
3990    /* *
3991     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_GetRemoteAddress_0100
3992     * @tc.name  : testNetworkMgrSocketTCPSocketGetRemoteAddress0100
3993     * @tc.desc  : Get the Opposite Socket Address,before bind or listen; callback
3994     * @tc.size  : MediumTest
3995     * @tc.type  : Function
3996     * @tc.level : level 2
3997     */
3998    it('testNetworkMgrSocketTCPSocketGetRemoteAddress0100', 0, async (done: Function) => {
3999      let caseName: string = 'testNetworkMgrSocketTCPSocketGetRemoteAddress0100';
4000      try {
4001        console.info(`${caseName} test start`);
4002        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
4003        expect(tcp).assertInstanceOf('Object');
4004        tcp.getRemoteAddress(async (err: BusinessError, data: socket.NetAddress) => {
4005          if (err) {
4006            console.info(`${caseName}_1 fail err:${JSON.stringify(err)}`);
4007            console.info(`${caseName} fail err:${JSON.stringify(err)}`);
4008            expectEqual(err.code, 2301009);
4009          } else {
4010            console.info(`${caseName} success data:${JSON.stringify(data)}`);
4011            expectFail();
4012          }
4013          console.info(`${caseName} test end`);
4014          done();
4015        });
4016      } catch (err) {
4017        console.info(`${caseName}_catch fail err:${JSON.stringify(err)}`);
4018        expectFail();
4019        console.info(`${caseName} test end`);
4020        done();
4021      }
4022    });
4023
4024    /* *
4025     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_GetRemoteAddress_0200
4026     * @tc.name  : testNetworkMgrSocketTCPSocketGetRemoteAddress0200
4027     * @tc.desc  : Get the Opposite Socket Address,after bind and connect; callback
4028     * @tc.size  : MediumTest
4029     * @tc.type  : Function
4030     * @tc.level : level 2
4031     */
4032    it('testNetworkMgrSocketTCPSocketGetRemoteAddress0200', 0, async (done: Function) => {
4033      let caseName: string = 'testNetworkMgrSocketTCPSocketGetRemoteAddress0200';
4034      try {
4035        console.info(`${caseName} test start`);
4036        await sleep(500);
4037        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
4038        expect(tcp).assertInstanceOf('Object');
4039        let bindAddress: socket.NetAddress = {
4040          address: '127.0.0.1',
4041          port: 4066,
4042          family: 1
4043        };
4044        await tcp.bind(bindAddress);
4045        let tcpConnectOptions: socket.TCPConnectOptions = {
4046          address: bindAddress,
4047        };
4048        await tcp.connect(tcpConnectOptions);
4049        tcp.getRemoteAddress(async (err: BusinessError, data: socket.NetAddress) => {
4050          if (err) {
4051            console.info(`${caseName}_1 fail err:${JSON.stringify(err)}`);
4052            expectFail();
4053          } else {
4054            console.info(`${caseName} success data:${JSON.stringify(data)}`);
4055            expectEqual(data.address as string, '127.0.0.1');
4056            expectEqual(data.port as number, 4066);
4057            expectEqual(data.family as number, 1);
4058          }
4059          await tcp.close();
4060          console.info(`${caseName} test end`);
4061          done();
4062        });
4063      } catch (err) {
4064        console.info(`${caseName}_catch fail err:${JSON.stringify(err)}`);
4065        expectFail();
4066        console.info(`${caseName} test end`);
4067        done();
4068      }
4069    });
4070
4071    /* *
4072     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_GetRemoteAddress_0300
4073     * @tc.name  : testNetworkMgrSocketTCPSocketGetRemoteAddress0300
4074     * @tc.desc  : Get the Opposite Socket Address, after listen and connect; callback
4075     * @tc.size  : MediumTest
4076     * @tc.type  : Function
4077     * @tc.level : level 2
4078     */
4079    it('testNetworkMgrSocketTCPSocketGetRemoteAddress0300', 0, async (done: Function) => {
4080      let caseName: string = 'testNetworkMgrSocketTCPSocketGetRemoteAddress0300';
4081      try {
4082        console.info(`${caseName} test start`);
4083        await sleep(500);
4084        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
4085        expect(tcp).assertInstanceOf('Object');
4086        let tcpServer: socket.TCPSocketServer = socket.constructTCPSocketServerInstance();
4087        expect(tcpServer).assertInstanceOf('Object');
4088        let listenAddress: socket.NetAddress = {
4089          address: '127.0.0.1',
4090          port: 4067,
4091          family: 1
4092        };
4093        await tcpServer.listen(listenAddress);
4094        let tcpConnectOptions: socket.TCPConnectOptions = {
4095          address: listenAddress,
4096        };
4097        await tcp.connect(tcpConnectOptions);
4098        tcp.getRemoteAddress(async (err: BusinessError, data: socket.NetAddress) => {
4099          if (err) {
4100            console.info(`${caseName} fail ${JSON.stringify(err)}`);
4101            expectFail();
4102          } else {
4103            console.info(`${caseName} success data:${JSON.stringify(data)}`);
4104            expectEqual(data.address as string, '127.0.0.1');
4105            expectEqual(data.port as number, 4067);
4106            expectEqual(data.family as number, 1);
4107          }
4108          await tcp.close();
4109          console.info(`${caseName} test end`);
4110          done();
4111        });
4112      } catch (err) {
4113        console.info(`${caseName}_catch fail err:${JSON.stringify(err)}`)
4114        expectFail();
4115        console.info(`${caseName} test end`);
4116        done();
4117      }
4118    });
4119
4120    /* *
4121     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_GetRemoteAddress_0400
4122     * @tc.name  : testNetworkMgrSocketTCPSocketGetRemoteAddress0400
4123     * @tc.desc  : Get the Opposite Socket Address,before bind or listen; promise
4124     * @tc.size  : MediumTest
4125     * @tc.type  : Function
4126     * @tc.level : level 2
4127     */
4128    it('testNetworkMgrSocketTCPSocketGetRemoteAddress0400', 0, async (done: Function) => {
4129      let caseName: string = 'testNetworkMgrSocketTCPSocketGetRemoteAddress0400';
4130      console.info(`${caseName} test start`);
4131      try {
4132        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
4133        expect(tcp).assertInstanceOf('Object');
4134        tcp.getRemoteAddress().then((data: socket.NetAddress) => {
4135          console.info(`${caseName} success data:${JSON.stringify(data)}`);
4136          expectFail();
4137          done();
4138        }).catch((err: BusinessError) => {
4139          console.info(`${caseName}_1 fail err:${JSON.stringify(err)}`);
4140          expectTrue(err.code===2301009);
4141          done();
4142        }).finally(async () => {
4143          console.info(`${caseName} test end`);
4144          done();
4145        });
4146      } catch (err) {
4147        console.info(`${caseName}_2 fail err:${JSON.stringify(err)}`);
4148        expectFail();
4149        console.info(`${caseName} test end`);
4150        done();
4151      }
4152    });
4153
4154    /* *
4155     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_GetRemoteAddress_0500
4156     * @tc.name  : testNetworkMgrSocketTCPSocketGetRemoteAddress0500
4157     * @tc.desc  : Get the Opposite Socket Address, after bind and connect; promise
4158     * @tc.size  : MediumTest
4159     * @tc.type  : Function
4160     * @tc.level : level 2
4161     */
4162    it('testNetworkMgrSocketTCPSocketGetRemoteAddress0500', 0, async (done: Function) => {
4163      let caseName: string = 'testNetworkMgrSocketTCPSocketGetRemoteAddress0500';
4164      console.info(`${caseName} test start`);
4165      await sleep(500);
4166      try {
4167        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
4168        expect(tcp).assertInstanceOf('Object');
4169        let bindAddress: socket.NetAddress = {
4170          address: '127.0.0.1',
4171          port: 4068,
4172          family:1
4173        };
4174        await tcp.bind(bindAddress);
4175        let tcpConnectOptions: socket.TCPConnectOptions = {
4176          address: bindAddress,
4177        };
4178        await tcp.connect(tcpConnectOptions);
4179        tcp.getRemoteAddress().then((data: socket.NetAddress) => {
4180          console.info(`${caseName} success data:${JSON.stringify(data)}`);
4181          expectEqual(data.address as string, '127.0.0.1');
4182          expectEqual(data.port as number, 4068);
4183          expectEqual(data.family as number, 1);
4184          done();
4185        }).catch((err: BusinessError) => {
4186          console.info(`${caseName}_1 fail err:${JSON.stringify(err)}`);
4187          expectFail();
4188          done();
4189        }).finally(async () => {
4190          await tcp.close();
4191          console.info(`${caseName} test end`);
4192          done();
4193        });
4194      } catch (err) {
4195        console.info(`${caseName}_catch fail err:${JSON.stringify(err)}`);
4196        expectFail();
4197        console.info(`${caseName} test end`);
4198        done();
4199      }
4200    });
4201
4202    /* *
4203     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_GetRemoteAddress_0600
4204     * @tc.name  : testNetworkMgrSocketTCPSocketGetRemoteAddress0600
4205     * @tc.desc  : Get the Opposite Socket Address,after listen and connect; promise
4206     * @tc.size  : MediumTest
4207     * @tc.type  : Function
4208     * @tc.level : level 2
4209     */
4210    it('testNetworkMgrSocketTCPSocketGetRemoteAddress0600', 0, async (done: Function) => {
4211      let caseName: string = 'testNetworkMgrSocketTCPSocketGetRemoteAddress0600';
4212      console.info(`${caseName} test start`);
4213      await sleep(500);
4214      try {
4215        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
4216        expect(tcp).assertInstanceOf('Object');
4217        let tcpServer: socket.TCPSocketServer = socket.constructTCPSocketServerInstance();
4218        expect(tcpServer).assertInstanceOf('Object');
4219        let listenAddress: socket.NetAddress = {
4220          address: '127.0.0.1',
4221          port: 4069,
4222          family:1
4223        };
4224        await tcpServer.listen(listenAddress);
4225        let tcpConnectOptions: socket.TCPConnectOptions = {
4226          address: listenAddress,
4227        };
4228        await tcp.connect(tcpConnectOptions);
4229        tcp.getRemoteAddress().then((data: socket.NetAddress) => {
4230          console.info(`${caseName} success data:${JSON.stringify(data)}`);
4231          expectEqual(data.address as string, '127.0.0.1');
4232          expectEqual(data.port as number, 4069);
4233          expectEqual(data.family as number, 1);
4234          done();
4235        }).catch((err: BusinessError) => {
4236          console.info(`${caseName} fail err:${JSON.stringify(err)}`);
4237          expectFail();
4238          done();
4239        }).finally(async () => {
4240          await tcp.close();
4241          console.info(`${caseName} test end`);
4242          done();
4243        });
4244      } catch (err) {
4245        console.info(`${caseName}_catch fail err:${JSON.stringify(err)}`);
4246        expectFail();
4247        console.info(`${caseName} test end`);
4248        done();
4249      }
4250    });
4251
4252    /* *
4253     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_GetState_0100
4254     * @tc.name  : testNetworkMgrSocketTCPSocketGetState0100
4255     * @tc.desc  : Get TCPSocket status,before bind or listen; callback
4256     * @tc.size  : MediumTest
4257     * @tc.type  : Function
4258     * @tc.level : level 2
4259     */
4260    it('testNetworkMgrSocketTCPSocketGetState0100', 0, async (done: Function) => {
4261      let caseName: string = 'testNetworkMgrSocketTCPSocketGetState0100';
4262      try {
4263        console.info(`${caseName} test start`);
4264        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
4265        expect(tcp).assertInstanceOf('Object');
4266        tcp.getState((err: BusinessError, data: socket.SocketStateBase) => {
4267          if (err) {
4268            console.info(`${caseName} fail err:${JSON.stringify(err)}`);
4269            expectFail();
4270          } else {
4271            console.info(`${caseName} success data:${JSON.stringify(data)}`);
4272            expectEqual(data.isBound as boolean, false);
4273            expectEqual(data.isClose as boolean, false);
4274            expectEqual(data.isConnected as boolean, false);
4275          }
4276          console.info(`${caseName} test end`);
4277          tcp.close();
4278          done();
4279        });
4280      } catch (err) {
4281        console.info(`${caseName}_catch fail err:${JSON.stringify(err)}`);
4282        expectFail();
4283        console.info(`${caseName} test end`);
4284        done();
4285      }
4286    });
4287
4288    /* *
4289     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_GetState_0200
4290     * @tc.name  : testNetworkMgrSocketTCPSocketGetState0200
4291     * @tc.desc  : Get TCPSocket status,after bind; callback
4292     * @tc.size  : MediumTest
4293     * @tc.type  : Function
4294     * @tc.level : level 2
4295     */
4296    it('testNetworkMgrSocketTCPSocketGetState0200', 0, async (done: Function) => {
4297      let caseName: string = 'testNetworkMgrSocketTCPSocketGetState0200';
4298      try {
4299        console.info(`${caseName} test start`);
4300        await sleep(500);
4301        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
4302        expect(tcp).assertInstanceOf('Object');
4303        let bindAddress: socket.NetAddress = {
4304          address: '127.0.0.1',
4305          port: 4070
4306        };
4307        await tcp.bind(bindAddress);
4308        tcp.getState(async (err: BusinessError, data: socket.SocketStateBase) => {
4309          if (err) {
4310            console.info(`${caseName}_1 fail err:${JSON.stringify(err)}`);
4311            expectFail();
4312          } else {
4313            console.info(`${caseName} success data:${JSON.stringify(data)}`);
4314            expectEqual(data.isBound as boolean, true);
4315            expectEqual(data.isClose as boolean, false);
4316            expectEqual(data.isConnected as boolean, false);
4317          }
4318          await tcp.close();
4319          console.info(`${caseName} test end`);
4320          done();
4321        });
4322      } catch (err) {
4323        console.info(`${caseName}_catch fail err:${JSON.stringify(err)}`);
4324        expectFail();
4325        console.info(`${caseName} test end`);
4326        done();
4327      }
4328    });
4329
4330    /* *
4331     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_GetState_0300
4332     * @tc.name  : testNetworkMgrSocketTCPSocketGetState0300
4333     * @tc.desc  : Get TCPSocket status,after bind and connect; callback
4334     * @tc.size  : MediumTest
4335     * @tc.type  : Function
4336     * @tc.level : level 2
4337     */
4338    it('testNetworkMgrSocketTCPSocketGetState0300', 0, async (done: Function) => {
4339      let caseName: string = 'testNetworkMgrSocketTCPSocketGetState0300';
4340      try {
4341        console.info(`${caseName} test start`);
4342        await sleep(500);
4343        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
4344        expect(tcp).assertInstanceOf('Object');
4345        let bindAddress: socket.NetAddress = {
4346          address: '127.0.0.1',
4347          port: 4071
4348        };
4349        await tcp.bind(bindAddress);
4350        let tcpConnectOptions: socket.TCPConnectOptions = {
4351          address: bindAddress,
4352        };
4353        await tcp.connect(tcpConnectOptions);
4354        tcp.getState(async (err: BusinessError, data: socket.SocketStateBase) => {
4355          if (err) {
4356            console.info(`${caseName}_1 fail err:${JSON.stringify(err)}`);
4357            expectFail();
4358          } else {
4359            console.info(`${caseName} success data:${JSON.stringify(data)}`);
4360            expectEqual(data.isBound as boolean, true);
4361            expectEqual(data.isClose as boolean, false);
4362            expectEqual(data.isConnected as boolean, true);
4363          }
4364          await tcp.close();
4365          console.info(`${caseName} test end`);
4366          done();
4367        });
4368      } catch (err) {
4369        console.info(`${caseName}_catch fail err:${JSON.stringify(err)}`);
4370        expectFail();
4371        console.info(`${caseName} test end`);
4372        done();
4373      }
4374    });
4375
4376    /* *
4377     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_GetState_0400
4378     * @tc.name  : testNetworkMgrSocketTCPSocketGetState0400
4379     * @tc.desc  : Get TCPSocket status,after listen and connect; callback
4380     * @tc.size  : MediumTest
4381     * @tc.type  : Function
4382     * @tc.level : level 2
4383     */
4384    it('testNetworkMgrSocketTCPSocketGetState0400', 0, async (done: Function) => {
4385      let caseName: string = 'testNetworkMgrSocketTCPSocketGetState0400';
4386      try {
4387        console.info(`${caseName} test start`);
4388        await sleep(500);
4389        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
4390        expect(tcp).assertInstanceOf('Object');
4391        let tcpServer: socket.TCPSocketServer = socket.constructTCPSocketServerInstance();
4392        expect(tcpServer).assertInstanceOf('Object');
4393        let listenAddress: socket.NetAddress = {
4394          address: '127.0.0.1',
4395          port: 4072,
4396          family: 1
4397        };
4398        await tcpServer.listen(listenAddress);
4399        let tcpConnectOptions: socket.TCPConnectOptions = {
4400          address: listenAddress,
4401        };
4402        await tcp.connect(tcpConnectOptions);
4403        tcp.getState(async (err: BusinessError, data: socket.SocketStateBase) => {
4404          if (err) {
4405            console.info(`${caseName}_1 fail err:${JSON.stringify(err)}`);
4406            expectFail();
4407          } else {
4408            console.info(`${caseName} success data:${JSON.stringify(data)}`);
4409            expectEqual(data.isBound as boolean, true);
4410            expectEqual(data.isClose as boolean, false);
4411            expectEqual(data.isConnected as boolean, true);
4412          }
4413          await tcp.close();
4414          console.info(`${caseName} test end`);
4415          done();
4416        });
4417      } catch (err) {
4418        console.info(`${caseName}_catch fail err:${JSON.stringify(err)}`);
4419        expectFail();
4420        console.info(`${caseName} test end`);
4421        done();
4422      }
4423    });
4424
4425    /* *
4426     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_GetState_0500
4427     * @tc.name  : testNetworkMgrSocketTCPSocketGetState0500
4428     * @tc.desc  : Get TCPSocket status,before bind or listen; callback
4429     * @tc.size  : MediumTest
4430     * @tc.type  : Function
4431     * @tc.level : level 2
4432     */
4433    it('testNetworkMgrSocketTCPSocketGetState0500', 0, async (done: Function) => {
4434      let caseName: string = 'testNetworkMgrSocketTCPSocketGetState0500';
4435      try {
4436        console.info(`${caseName} test start`);
4437        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
4438        expect(tcp).assertInstanceOf('Object');
4439        tcp.getState().then((data: socket.SocketStateBase) => {
4440          console.info(`${caseName} success data:${JSON.stringify(data)}`);
4441          expectEqual(data.isBound as boolean, false);
4442          expectEqual(data.isClose as boolean, false);
4443          expectEqual(data.isConnected as boolean, false);
4444          tcp.close();
4445          done();
4446        }).catch((err: BusinessError) => {
4447          console.info(`${caseName} fail err:${JSON.stringify(err)}`);
4448          expectFail();
4449          done();
4450        }).finally(() => {
4451          console.info(`${caseName} test end`);
4452          done();
4453        });
4454      } catch (err) {
4455        console.info(`${caseName}_catch fail err:${JSON.stringify(err)}`);
4456        expectFail();
4457        console.info(`${caseName} test end`);
4458        done();
4459      }
4460    });
4461
4462    /* *
4463     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_GetState_0600
4464     * @tc.name  : testNetworkMgrSocketTCPSocketGetState0600
4465     * @tc.desc  : Get TCPSocket status; promise
4466     * @tc.size  : MediumTest
4467     * @tc.type  : Function
4468     * @tc.level : level 2
4469     */
4470    it('testNetworkMgrSocketTCPSocketGetState0600', 0, async (done: Function) => {
4471      let caseName: string = 'testNetworkMgrSocketTCPSocketGetState0600'
4472      console.info(`${caseName} test start`);
4473      await sleep(500);
4474      try {
4475        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
4476        expect(tcp).assertInstanceOf('Object');
4477        let bindAddress: socket.NetAddress = {
4478          address: '127.0.0.1',
4479          port: 4073
4480        };
4481        await tcp.bind(bindAddress);
4482        await tcp.getState().then((data: socket.SocketStateBase) => {
4483          console.info(`${caseName} success data:${JSON.stringify(data)}`);
4484          expectEqual(data.isBound as boolean, true);
4485          expectEqual(data.isClose as boolean, false);
4486          expectEqual(data.isConnected as boolean, false);
4487          done();
4488        }).catch((err: BusinessError) => {
4489          console.info(`${caseName} Fail err:${JSON.stringify(err)}`);
4490          expectFail();
4491          done();
4492        }).finally(async () => {
4493          await tcp.close();
4494          console.info(`${caseName} test end`);
4495          done();
4496        });
4497      } catch (err) {
4498        console.info(`${caseName}_catch fail err:${JSON.stringify(err)}`);
4499        expectFail();
4500        console.info(`${caseName} test end`);
4501        done();
4502      }
4503    });
4504
4505    /* *
4506     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_GetState_0700
4507     * @tc.name  : testNetworkMgrSocketTCPSocketGetState0700
4508     * @tc.desc  : Get TCPSocket status; promise
4509     * @tc.size  : MediumTest
4510     * @tc.type  : Function
4511     * @tc.level : level 2
4512     */
4513    it('testNetworkMgrSocketTCPSocketGetState0700', 0, async (done: Function) => {
4514      let caseName: string = 'testNetworkMgrSocketTCPSocketGetState0700';
4515      try {
4516        console.info(`${caseName} test start`);
4517        await sleep(500);
4518        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
4519        expect(tcp).assertInstanceOf('Object');
4520        let bindAddress: socket.NetAddress = {
4521          address: '127.0.0.1',
4522          port: 4074
4523        };
4524        await tcp.bind(bindAddress);
4525        let tcpConnectOptions: socket.TCPConnectOptions = {
4526          address: bindAddress,
4527        };
4528        await tcp.connect(tcpConnectOptions);
4529        tcp.getState().then((data: socket.SocketStateBase) => {
4530          console.info(`${caseName} success data:${JSON.stringify(data)}`);
4531          expectEqual(data.isBound as boolean, true);
4532          expectEqual(data.isClose as boolean, false);
4533          expectEqual(data.isConnected as boolean, true);
4534          done();
4535        }).catch((err: BusinessError) => {
4536          console.info(`${caseName} Fail err:${JSON.stringify(err)}`);
4537          expectFail();
4538          done();
4539        }).finally(async () => {
4540          tcp.close();
4541          console.info(`${caseName} test end`);
4542          done();
4543        });
4544      } catch (err) {
4545        console.info(`${caseName}_catch fail err:${JSON.stringify(err)}`);
4546        expectFail();
4547        console.info(`${caseName} test end`);
4548        done();
4549      }
4550    });
4551
4552    /* *
4553     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_GetState_0800
4554     * @tc.name  : testNetworkMgrSocketTCPSocketGetState0800
4555     * @tc.desc  : Get TCPSocket status; promise
4556     * @tc.size  : MediumTest
4557     * @tc.type  : Function
4558     * @tc.level : level 2
4559     */
4560    it('testNetworkMgrSocketTCPSocketGetState0800', 0, async (done: Function) => {
4561      let caseName: string = 'testNetworkMgrSocketTCPSocketGetState0800';
4562      try {
4563        console.info(`${caseName} test start`);
4564        await sleep(500);
4565        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
4566        expect(tcp).assertInstanceOf('Object');
4567        let tcpServer: socket.TCPSocketServer = socket.constructTCPSocketServerInstance();
4568        expect(tcpServer).assertInstanceOf('Object');
4569        let listenAddress: socket.NetAddress = {
4570          address: '127.0.0.1',
4571          port: 4075,
4572          family: 1
4573        };
4574        await tcpServer.listen(listenAddress);
4575        let tcpConnectOptions: socket.TCPConnectOptions = {
4576          address: listenAddress,
4577        };
4578        await tcp.connect(tcpConnectOptions);
4579        tcp.getState().then((data: socket.SocketStateBase) => {
4580          console.info(`${caseName} success data:${JSON.stringify(data)}`);
4581          expectEqual(data.isBound as boolean, true);
4582          expectEqual(data.isClose as boolean, false);
4583          expectEqual(data.isConnected as boolean, true);
4584          done();
4585        }).catch((err: BusinessError) => {
4586          console.info(`${caseName} Fail err:${JSON.stringify(err)}`);
4587          expectFail();
4588          done();
4589        }).finally(async () => {
4590          tcp.close();
4591          console.info(`${caseName} test end`);
4592          done();
4593        });
4594      } catch (err) {
4595        console.info(`${caseName}_catch fail err:${JSON.stringify(err)}`);
4596        expectFail();
4597        console.info(`${caseName} test end`);
4598        done();
4599      }
4600    });
4601
4602    /* *
4603     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_GetSocketFd_0100
4604     * @tc.name  : testNetworkMgrSocketTCPSocketGetSocketFd0100
4605     * @tc.desc  : Get TCPSocket status,before bind or listen; callback
4606     * @tc.size  : MediumTest
4607     * @tc.type  : Function
4608     * @tc.level : level 2
4609     */
4610    it('testNetworkMgrSocketTCPSocketGetSocketFd0100', 0, async (done: Function) => {
4611      let caseName: string = 'testNetworkMgrSocketTCPSocketGetSocketFd0100';
4612      try {
4613        console.info(`${caseName} test start`);
4614        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
4615        expect(tcp).assertInstanceOf('Object');
4616        tcp.getSocketFd((err: BusinessError, data: number) => {
4617          if (err) {
4618            console.info(`${caseName} fail ${JSON.stringify(err)}`);
4619            expectFail();
4620          } else {
4621            console.info(`${caseName} success: ${JSON.stringify(data)}`);
4622            expectTrue(data === undefined);
4623          }
4624          console.info(`${caseName} test end`);
4625          done();
4626        });
4627      } catch (err) {
4628        console.info(`${caseName}_catch fail err:${JSON.stringify(err)}`);
4629        expectFail();
4630        console.info(`${caseName} test end`);
4631        done();
4632      }
4633    });
4634
4635    /* *
4636     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_GetSocketFd_0200
4637     * @tc.name  : testNetworkMgrSocketTCPSocketGetSocketFd0200
4638     * @tc.desc  : Get TCPSocket status,after bind; callback
4639     * @tc.size  : MediumTest
4640     * @tc.type  : Function
4641     * @tc.level : level 2
4642     */
4643    it('testNetworkMgrSocketTCPSocketGetSocketFd0200', 0, async (done: Function) => {
4644      let caseName: string = 'testNetworkMgrSocketTCPSocketGetSocketFd0200';
4645      try {
4646        console.info(`${caseName} test start`);
4647        await sleep(500);
4648        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
4649        expect(tcp).assertInstanceOf('Object');
4650        let bindAddress: socket.NetAddress = {
4651          address: '127.0.0.1',
4652          port: 4076
4653        };
4654        await tcp.bind(bindAddress);
4655        tcp.getSocketFd(async (err: BusinessError, data: number) => {
4656          if (err) {
4657            console.info(`${caseName} fail err:${JSON.stringify(err)}`);
4658            expectFail();
4659          } else {
4660            console.info(`${caseName} success data:${JSON.stringify(data)}`);
4661            expectTrue(data !== undefined);
4662          }
4663          await tcp.close();
4664          console.info(`${caseName} test end`);
4665          done();
4666        });
4667      } catch (err) {
4668        console.info(`${caseName}_catch fail err:${JSON.stringify(err)}`);
4669        expectFail();
4670        console.info(`${caseName} test end`);
4671        done();
4672      }
4673    });
4674
4675    /* *
4676     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_GetSocketFd_0300
4677     * @tc.name  : testNetworkMgrSocketTCPSocketGetSocketFd0300
4678     * @tc.desc  : Get TCPSocket status,after bind and connect; callback
4679     * @tc.size  : MediumTest
4680     * @tc.type  : Function
4681     * @tc.level : level 2
4682     */
4683    it('testNetworkMgrSocketTCPSocketGetSocketFd0300', 0, async (done: Function) => {
4684      let caseName: string = 'testNetworkMgrSocketTCPSocketGetSocketFd0300';
4685      try {
4686        console.info(`${caseName} test start`);
4687        await sleep(500);
4688        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
4689        expect(tcp).assertInstanceOf('Object');
4690        let bindAddress: socket.NetAddress = {
4691          address: '127.0.0.1',
4692          port: 4077
4693        };
4694        await tcp.bind(bindAddress);
4695        let tcpConnectOptions: socket.TCPConnectOptions = {
4696          address: bindAddress,
4697        };
4698        await tcp.connect(tcpConnectOptions);
4699        tcp.getSocketFd(async (err: BusinessError, data: number) => {
4700          if (err) {
4701            console.info(`${caseName}_1 fail err:${JSON.stringify(err)}`);
4702            expectFail();
4703          } else {
4704            console.info(`${caseName} success data:${JSON.stringify(data)}`);
4705            expectTrue(data !== undefined);
4706          }
4707          await tcp.close();
4708          console.info(`${caseName} test end`);
4709          done();
4710        });
4711      } catch (err) {
4712        console.info(`${caseName}_catch fail err:${JSON.stringify(err)}`);
4713        expectFail();
4714        console.info(`${caseName} test end`);
4715        done();
4716      }
4717    });
4718
4719    /* *
4720     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_GetSocketFd_0400
4721     * @tc.name  : testNetworkMgrSocketTCPSocketGetSocketFd0400
4722     * @tc.desc  : Get TCPSocket status,after listen and connect; callback
4723     * @tc.size  : MediumTest
4724     * @tc.type  : Function
4725     * @tc.level : level 2
4726     */
4727    it('testNetworkMgrSocketTCPSocketGetSocketFd0400', 0, async (done: Function) => {
4728      let caseName: string = 'testNetworkMgrSocketTCPSocketGetSocketFd0400';
4729      try {
4730        console.info(`${caseName} test start`);
4731        await sleep(500);
4732        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
4733        expect(tcp).assertInstanceOf('Object');
4734        let tcpServer: socket.TCPSocketServer = socket.constructTCPSocketServerInstance();
4735        expect(tcpServer).assertInstanceOf('Object');
4736        let listenAddress: socket.NetAddress = {
4737          address: '127.0.0.1',
4738          port: 4078,
4739          family: 1
4740        };
4741        await tcpServer.listen(listenAddress);
4742        let tcpConnectOptions: socket.TCPConnectOptions = {
4743          address: listenAddress,
4744        };
4745        await tcp.connect(tcpConnectOptions);
4746        tcp.getSocketFd(async (err: BusinessError, data: number) => {
4747          if (err) {
4748            console.info(`${caseName} fail err:${JSON.stringify(err)}`);
4749            expectFail();
4750          } else {
4751            console.info(`${caseName} success data:${JSON.stringify(data)}`);
4752            expectTrue(data !== undefined);
4753          }
4754          await tcp.close();
4755          console.info(`${caseName} test end`);
4756          done();
4757        });
4758      } catch (err) {
4759        console.info(`${caseName}_catch fail err:${JSON.stringify(err)}`);
4760        expectFail();
4761        console.info(`${caseName} test end`);
4762        done();
4763      }
4764    });
4765
4766    /* *
4767     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_GetSocketFd_0500
4768     * @tc.name  : testNetworkMgrSocketTCPSocketGetSocketFd0500
4769     * @tc.desc  : Get TCPSocket status, before bind or listen; promise
4770     * @tc.size  : MediumTest
4771     * @tc.type  : Function
4772     * @tc.level : level 2
4773     */
4774    it('testNetworkMgrSocketTCPSocketGetSocketFd0500', 0, async (done: Function) => {
4775      let caseName: string = 'testNetworkMgrSocketTCPSocketGetSocketFd0500';
4776      try {
4777        console.info(`${caseName} test start`);
4778        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
4779        expect(tcp).assertInstanceOf('Object');
4780        tcp.getSocketFd().then((data: number) => {
4781          console.info(`${caseName} fail data:${JSON.stringify(data)}`);
4782          expectTrue(data === undefined);
4783          done();
4784        }).catch((err: BusinessError) => {
4785          console.info(`${caseName} fail err:${JSON.stringify(err)}`);
4786          expectFail();
4787          done();
4788        }).finally(() => {
4789          console.info(`${caseName} test end`);
4790          done();
4791        });
4792      } catch (err) {
4793        console.info(`${caseName}_catch fail err:${JSON.stringify(err)}`);
4794        expectFail();
4795        console.info(`${caseName} test end`);
4796        done();
4797      }
4798    });
4799
4800    /* *
4801     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_GetSocketFd_0600
4802     * @tc.name  : testNetworkMgrSocketTCPSocketGetSocketFd0600
4803     * @tc.desc  : Get TCPSocket status,after bind; promise
4804     * @tc.size  : MediumTest
4805     * @tc.type  : Function
4806     * @tc.level : level 2
4807     */
4808    it('testNetworkMgrSocketTCPSocketGetSocketFd0600', 0, async (done: Function) => {
4809      let caseName: string = 'testNetworkMgrSocketTCPSocketGetSocketFd0600';
4810      try {
4811        console.info(`${caseName} test start`);
4812        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
4813        expect(tcp).assertInstanceOf('Object');
4814        let bindAddress: socket.NetAddress = {
4815          address: '127.0.0.1',
4816          port: 4079
4817        };
4818        await tcp.bind(bindAddress);
4819        tcp.getSocketFd().then((data: number) => {
4820          console.info(`${caseName} success data:${JSON.stringify(data)}`);
4821          expectTrue(data !== undefined);
4822          done();
4823        }).catch((err: BusinessError) => {
4824          console.info(`${caseName} fail err:${JSON.stringify(err)}`);
4825          expectFail();
4826          done();
4827        }).finally(async () => {
4828          await tcp.close();
4829          console.info(`${caseName} test end`);
4830          done();
4831        })
4832      } catch (err) {
4833        console.info(`${caseName}_catch fail err:${JSON.stringify(err)}`);
4834        expectFail();
4835        console.info(`${caseName} test end`);
4836        done();
4837      }
4838    });
4839
4840    /* *
4841     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_GetSocketFd_0700
4842     * @tc.name  : testNetworkMgrSocketTCPSocketGetSocketFd0700
4843     * @tc.desc  : Get TCPSocket status,after bind and connect; promise
4844     * @tc.size  : MediumTest
4845     * @tc.type  : Function
4846     * @tc.level : level 2
4847     */
4848    it('testNetworkMgrSocketTCPSocketGetSocketFd0700', 0, async (done: Function) => {
4849      let caseName: string = 'testNetworkMgrSocketTCPSocketGetSocketFd0700';
4850      try {
4851        console.info(`${caseName} test start`);
4852        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
4853        expect(tcp).assertInstanceOf('Object')
4854        let bindAddress: socket.NetAddress = {
4855          address: '127.0.0.1',
4856          port: 4080
4857        };
4858        await tcp.bind(bindAddress);
4859        let tcpConnectOptions: socket.TCPConnectOptions = {
4860          address: bindAddress,
4861        };
4862        await tcp.connect(tcpConnectOptions);
4863        tcp.getSocketFd().then((data: number) => {
4864          console.info(`${caseName} success data:${JSON.stringify(data)}`);
4865          expectTrue(data !== undefined);
4866          done();
4867        }).catch((err: BusinessError) => {
4868          console.info(`${caseName}_1 fail err:${JSON.stringify(err)}`);
4869          expectFail();
4870          done();
4871        }).finally(async () => {
4872          await tcp.close();
4873          console.info(`${caseName} test end`);
4874          done();
4875        });
4876      } catch (err) {
4877        console.info(`${caseName}_catch fail err:${JSON.stringify(err)}`);
4878        expectFail();
4879        console.info(`${caseName} test end`);
4880        done();
4881      }
4882    });
4883
4884    /* *
4885     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_GetSocketFd_0800
4886     * @tc.name  : testNetworkMgrSocketTCPSocketGetSocketFd0800
4887     * @tc.desc  : Get TCPSocket status,after listen and connect; promise
4888     * @tc.size  : MediumTest
4889     * @tc.type  : Function
4890     * @tc.level : level 2
4891     */
4892    it('testNetworkMgrSocketTCPSocketGetSocketFd0800', 0, async (done: Function) => {
4893      let caseName: string = 'testNetworkMgrSocketTCPSocketGetSocketFd0800';
4894      try {
4895        console.info(`${caseName} test start`);
4896        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
4897        expect(tcp).assertInstanceOf('Object')
4898        let tcpServer: socket.TCPSocketServer = socket.constructTCPSocketServerInstance();
4899        expect(tcpServer).assertInstanceOf('Object')
4900        let listenAddress: socket.NetAddress = {
4901          address: '127.0.0.1',
4902          port: 4081,
4903          family: 1
4904        };
4905        await tcpServer.listen(listenAddress);
4906        let tcpConnectOptions: socket.TCPConnectOptions = {
4907          address: listenAddress,
4908        };
4909        await tcp.connect(tcpConnectOptions);
4910        tcp.getSocketFd().then((data: number) => {
4911          console.info(`${caseName} success data:${JSON.stringify(data)}`);
4912          expectTrue(data !== undefined);
4913          done();
4914        }).catch((err: BusinessError) => {
4915          console.info(`${caseName} fail err:${JSON.stringify(err)}`);
4916          expectFail();
4917          done();
4918        }).finally(async () => {
4919          await tcp.close();
4920          console.info(`${caseName} test end`);
4921          done();
4922        });
4923      } catch (err) {
4924        console.info(`${caseName}_catch fail err:${JSON.stringify(err)}`);
4925        expectFail();
4926        console.info(`${caseName} test end`);
4927        done();
4928      }
4929    });
4930
4931    /* *
4932     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_SetExtraOptions_0100
4933     * @tc.name  : testNetworkMgrSocketTCPSocketSetExtraOptions0100
4934     * @tc.desc  : Get TCPSocket status,after bind;  callback
4935     * @tc.size  : MediumTest
4936     * @tc.type  : Function
4937     * @tc.level : level 2
4938     */
4939    it('testNetworkMgrSocketTCPSocketSetExtraOptions0100', 0, async (done: Function) => {
4940      let caseName: string = 'testNetworkMgrSocketTCPSocketSetExtraOptions0100';
4941      try {
4942        console.info(`${caseName} test start`);
4943        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
4944        expect(tcp).assertInstanceOf('Object');
4945        let bindAddress: socket.NetAddress = {
4946          address: '127.0.0.1',
4947          port: 4082
4948        };
4949        await tcp.bind(bindAddress);
4950        let tcpExtraOptions: socket.TCPExtraOptions = {
4951          keepAlive: true,
4952          OOBInline: true,
4953          TCPNoDelay: true,
4954          socketLinger: {
4955            on: true, linger: 10
4956          },
4957          receiveBufferSize: 1000,
4958          sendBufferSize: 1000,
4959          reuseAddress: true,
4960          socketTimeout: 3000
4961        };
4962        tcp.setExtraOptions(tcpExtraOptions, async (err: BusinessError) => {
4963          if (err) {
4964            console.info(`${caseName} fail err:${JSON.stringify(err)}`);
4965            expectFail();
4966          } else {
4967            console.info(`${caseName} success`);
4968            expectSuccess();
4969          }
4970          await tcp.close();
4971          console.info(`${caseName} test end`);
4972          done();
4973        });
4974      } catch (err) {
4975        console.info(`${caseName}_catch fail err:${JSON.stringify(err)}`);
4976        expectFail();
4977        console.info(`${caseName} test end`);
4978        done();
4979      }
4980    });
4981
4982    /* *
4983     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_SetExtraOptions_0200
4984     * @tc.name  : testNetworkMgrSocketTCPSocketSetExtraOptions0200
4985     * @tc.desc  : Get TCPSocket status,after bind and connect; callback
4986     * @tc.size  : MediumTest
4987     * @tc.type  : Function
4988     * @tc.level : level 2
4989     */
4990    it('testNetworkMgrSocketTCPSocketSetExtraOptions0200', 0, async (done: Function) => {
4991      let caseName: string = 'testNetworkMgrSocketTCPSocketSetExtraOptions0200';
4992      try {
4993        console.info(`${caseName} test start`);
4994        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
4995        expect(tcp).assertInstanceOf('Object');
4996        let bindAddress: socket.NetAddress = {
4997          address: '127.0.0.1',
4998          port: 4083
4999        };
5000        await tcp.bind(bindAddress);
5001        let tcpConnectOptions: socket.TCPConnectOptions = {
5002          address: bindAddress,
5003        };
5004        await tcp.connect(tcpConnectOptions);
5005        let tcpExtraOptions: socket.TCPExtraOptions = {
5006          keepAlive: true,
5007          OOBInline: true,
5008          TCPNoDelay: true,
5009          socketLinger: {
5010            on: true, linger: 10
5011          },
5012          receiveBufferSize: 1000,
5013          sendBufferSize: 1000,
5014          reuseAddress: true,
5015          socketTimeout: 3000
5016        };
5017        tcp.setExtraOptions(tcpExtraOptions, async (err: BusinessError) => {
5018          if (err) {
5019            console.info(`${caseName}_1 fail err:${JSON.stringify(err)}`);
5020            expectFail();
5021          } else {
5022            console.info(`${caseName} success`);
5023            expectSuccess();
5024          }
5025          await tcp.close();
5026          console.info(`${caseName} test end`);
5027          done();
5028        });
5029      } catch (err) {
5030        console.info(`${caseName}_catch fail err:${JSON.stringify(err)}`);
5031        expectFail();
5032        console.info(`${caseName} test end`);
5033        done();
5034      }
5035    });
5036
5037    /* *
5038     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_SetExtraOptions_0300
5039     * @tc.name  : testNetworkMgrSocketTCPSocketSetExtraOptions0300
5040     * @tc.desc  : Get TCPSocket status,after listen and connect; callback
5041     * @tc.size  : MediumTest
5042     * @tc.type  : Function
5043     * @tc.level : level 2
5044     */
5045    it('testNetworkMgrSocketTCPSocketSetExtraOptions0300', 0, async (done: Function) => {
5046      let caseName: string = 'testNetworkMgrSocketTCPSocketSetExtraOptions0300';
5047      try {
5048        console.info(`${caseName} test start`);
5049        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
5050        expect(tcp).assertInstanceOf('Object');
5051        let tcpServer: socket.TCPSocketServer = socket.constructTCPSocketServerInstance();
5052        expect(tcpServer).assertInstanceOf('Object');
5053        let listenAddress: socket.NetAddress = {
5054          address: '127.0.0.1',
5055          port: 4084,
5056          family: 1
5057        };
5058        await tcpServer.listen(listenAddress);
5059        let tcpConnectOptions: socket.TCPConnectOptions = {
5060          address: listenAddress,
5061        };
5062        await tcp.connect(tcpConnectOptions);
5063        let tcpExtraOptions: socket.TCPExtraOptions = {
5064          keepAlive: true,
5065          OOBInline: true,
5066          TCPNoDelay: true,
5067          socketLinger: {
5068            on: true, linger: 10
5069          },
5070          receiveBufferSize: 1000,
5071          sendBufferSize: 1000,
5072          reuseAddress: true,
5073          socketTimeout: 3000
5074        };
5075        tcp.setExtraOptions(tcpExtraOptions, async (err: BusinessError) => {
5076          if (err) {
5077            console.info(`${caseName} fail err:${JSON.stringify(err)}`);
5078            expectFail();
5079          } else {
5080            console.info(`${caseName} success`);
5081            expectSuccess();
5082          }
5083          await tcp.close();
5084          console.info(`${caseName} test end`);
5085          done();
5086        });
5087      } catch (err) {
5088        console.info(`${caseName}_catch fail err:${JSON.stringify(err)}`);
5089        expectFail();
5090        console.info(`${caseName} test end`);
5091        done();
5092      }
5093    });
5094
5095    /* *
5096     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_SetExtraOptions_0400
5097     * @tc.name  : testNetworkMgrSocketTCPSocketSetExtraOptions0400
5098     * @tc.desc  : Get TCPSocket status,Input parameter is null; callback
5099     * @tc.size  : MediumTest
5100     * @tc.type  : Function
5101     * @tc.level : level 2
5102     */
5103    it('testNetworkMgrSocketTCPSocketSetExtraOptions0400', 0, async (done: Function) => {
5104      let caseName: string = 'testNetworkMgrSocketTCPSocketSetExtraOptions0400';
5105      try {
5106        console.info(`${caseName} test start`);
5107        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
5108        expect(tcp).assertInstanceOf('Object');
5109        let bindAddress: socket.NetAddress = {
5110          address: '127.0.0.1',
5111          port: 4085
5112        };
5113        await tcp.bind(bindAddress);
5114        tcp.setExtraOptions(null, async (err: BusinessError) => {
5115          if (err) {
5116            console.info(`${caseName} fail 111 err:${JSON.stringify(err)}`);
5117            expectEqual(err.code, 401);
5118          } else {
5119            console.info(`${caseName} success`);
5120            expectFail();
5121          }
5122          await tcp.close();
5123          console.info(`${caseName} test end`);
5124          done();
5125        });
5126      } catch (err) {
5127        console.info(`${caseName}_catch fail err:${JSON.stringify(err)}`);
5128        expectFail();
5129        console.info(`${caseName} test end`);
5130        done();
5131      }
5132    });
5133
5134    /* *
5135     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_SetExtraOptions_0500
5136     * @tc.name  : testNetworkMgrSocketTCPSocketSetExtraOptions0500
5137     * @tc.desc  : Get TCPSocket status,Input parameter is undefined; callback
5138     * @tc.size  : MediumTest
5139     * @tc.type  : Function
5140     * @tc.level : level 2
5141     */
5142    it('testNetworkMgrSocketTCPSocketSetExtraOptions0500', 0, async (done: Function) => {
5143      let caseName: string = 'testNetworkMgrSocketTCPSocketSetExtraOptions0500';
5144      try {
5145        console.info(`${caseName} test start`);
5146        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
5147        expect(tcp).assertInstanceOf('Object');
5148        let bindAddress: socket.NetAddress = {
5149          address: '127.0.0.1',
5150          port: 4086
5151        };
5152        await tcp.bind(bindAddress);
5153        tcp.setExtraOptions(undefined, async (err: BusinessError) => {
5154          if (err) {
5155            console.info(`${caseName} fail 111 err:${JSON.stringify(err)}`);
5156            expectEqual(err.code, 401);
5157          } else {
5158            console.info(`${caseName} success`);
5159            expectFail();
5160          }
5161          await tcp.close();
5162          console.info(`${caseName} test end`);
5163          done();
5164        });
5165      } catch (err) {
5166        console.info(`${caseName}_catch fail err:${JSON.stringify(err)}`);
5167        expectFail();
5168        console.info(`${caseName} test end`);
5169        done();
5170      }
5171    });
5172
5173    /* *
5174     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_SetExtraOptions_0600
5175     * @tc.name  : testNetworkMgrSocketTCPSocketSetExtraOptions0600
5176     * @tc.desc  : Get TCPSocket status,Input parameter keepAlive is false; callback
5177     * @tc.size  : MediumTest
5178     * @tc.type  : Function
5179     * @tc.level : level 2
5180     */
5181    it('testNetworkMgrSocketTCPSocketSetExtraOptions0600', 0, async (done: Function) => {
5182      let caseName: string = 'testNetworkMgrSocketTCPSocketSetExtraOptions0600';
5183      try {
5184        console.info(`${caseName} test start`);
5185        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
5186        expect(tcp).assertInstanceOf('Object');
5187        let bindAddress: socket.NetAddress = {
5188          address: '127.0.0.1',
5189          port: 9001
5190        };
5191        await tcp.bind(bindAddress);
5192        let tcpExtraOptions: socket.TCPExtraOptions = {
5193          keepAlive: false,
5194          socketLinger: {
5195            on: true, linger: 10
5196          }
5197        };
5198        tcp.setExtraOptions(tcpExtraOptions, async (err: BusinessError) => {
5199          if (err) {
5200            console.info(`${caseName} fail err:${JSON.stringify(err)}`);
5201            expectFail();
5202          } else {
5203            console.info(`${caseName} success`);
5204            expectSuccess();
5205          }
5206          await tcp.close();
5207          console.info(`${caseName} test end`);
5208          done();
5209        });
5210      } catch (err) {
5211        console.info(`${caseName}_catch fail err:${JSON.stringify(err)}`);
5212        expectFail();
5213        console.info(`${caseName} test end`);
5214        done();
5215      }
5216    });
5217
5218    /* *
5219     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_SetExtraOptions_0700
5220     * @tc.name  : testNetworkMgrSocketTCPSocketSetExtraOptions0700
5221     * @tc.desc  : Get TCPSocket status,Input parameter keepAlive is true; callback
5222     * @tc.size  : MediumTest
5223     * @tc.type  : Function
5224     * @tc.level : level 2
5225     */
5226    it('testNetworkMgrSocketTCPSocketSetExtraOptions0700', 0, async (done: Function) => {
5227      let caseName: string = 'testNetworkMgrSocketTCPSocketSetExtraOptions0700';
5228      try {
5229        console.info(`${caseName} test start`);
5230        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
5231        expect(tcp).assertInstanceOf('Object');
5232        let bindAddress: socket.NetAddress = {
5233          address: '127.0.0.1',
5234          port: 9002
5235        };
5236        await tcp.bind(bindAddress);
5237        let tcpExtraOptions: socket.TCPExtraOptions = {
5238          keepAlive: true,
5239          socketLinger: {
5240            on: true, linger: 10
5241          }
5242        };
5243        tcp.setExtraOptions(tcpExtraOptions, async (err: BusinessError) => {
5244          if (err) {
5245            console.info(`${caseName} fail err:${JSON.stringify(err)}`);
5246            expectFail();
5247          } else {
5248            console.info(`${caseName} success`);
5249            expectSuccess();
5250          }
5251          await tcp.close();
5252          console.info(`${caseName} test end`);
5253          done();
5254        });
5255      } catch (err) {
5256        console.info(`${caseName}_catch fail err:${JSON.stringify(err)}`);
5257        expectFail();
5258        console.info(`${caseName} test end`);
5259        done();
5260      }
5261    });
5262
5263    /* *
5264     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_SetExtraOptions_0800
5265     * @tc.name  : testNetworkMgrSocketTCPSocketSetExtraOptions0800
5266     * @tc.desc  : Get TCPSocket status,Input parameter OOBlnLine is false ; callback
5267     * @tc.size  : MediumTest
5268     * @tc.type  : Function
5269     * @tc.level : level 2
5270     */
5271    it('testNetworkMgrSocketTCPSocketSetExtraOptions0800', 0, async (done: Function) => {
5272      let caseName: string = 'testNetworkMgrSocketTCPSocketSetExtraOptions0800';
5273      try {
5274        console.info(`${caseName} test start`);
5275        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
5276        expect(tcp).assertInstanceOf('Object');
5277        let bindAddress: socket.NetAddress = {
5278          address: '127.0.0.1',
5279          port: 9003
5280        };
5281        await tcp.bind(bindAddress);
5282        let tcpExtraOptions: socket.TCPExtraOptions = {
5283          OOBInline: false,
5284          socketLinger: {
5285            on: true, linger: 10
5286          }
5287        };
5288        tcp.setExtraOptions(tcpExtraOptions, async (err: BusinessError) => {
5289          if (err) {
5290            console.info(`${caseName} fail err:${JSON.stringify(err)}`);
5291            expectFail();
5292          } else {
5293            console.info(`${caseName} success`);
5294            expectSuccess();
5295          }
5296          await tcp.close();
5297          console.info(`${caseName} test end`);
5298          done();
5299        });
5300      } catch (err) {
5301        console.info(`${caseName}_catch fail err:${JSON.stringify(err)}`);
5302        expectFail();
5303        console.info(`${caseName} test end`);
5304        done();
5305      }
5306    });
5307
5308    /* *
5309     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_SetExtraOptions_0900
5310     * @tc.name  : testNetworkMgrSocketTCPSocketSetExtraOptions0900
5311     * @tc.desc  : Get TCPSocket status, Input parameter OOBlnLine is true; callback
5312     * @tc.size  : MediumTest
5313     * @tc.type  : Function
5314     * @tc.level : level 2
5315     */
5316    it('testNetworkMgrSocketTCPSocketSetExtraOptions0900', 0, async (done: Function) => {
5317      let caseName: string = 'testNetworkMgrSocketTCPSocketSetExtraOptions0900';
5318      try {
5319        console.info(`${caseName} test start`);
5320        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
5321        expect(tcp).assertInstanceOf('Object');
5322        let bindAddress: socket.NetAddress = {
5323          address: '127.0.0.1',
5324          port: 9004
5325        };
5326        await tcp.bind(bindAddress);
5327        let tcpExtraOptions: socket.TCPExtraOptions = {
5328          OOBInline: true,
5329          socketLinger: {
5330            on: true, linger: 10
5331          }
5332        };
5333        tcp.setExtraOptions(tcpExtraOptions, async (err: BusinessError) => {
5334          if (err) {
5335            console.info(`${caseName} fail err:${JSON.stringify(err)}`);
5336            expectFail();
5337          } else {
5338            console.info(`${caseName} success`);
5339            expectSuccess();
5340          }
5341          await tcp.close();
5342          console.info(`${caseName} test end`);
5343          done();
5344        });
5345      } catch (err) {
5346        console.info(`${caseName}_catch fail err:${JSON.stringify(err)}`);
5347        expectFail();
5348        console.info(`${caseName} test end`);
5349        done();
5350      }
5351    });
5352
5353    /* *
5354     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_SetExtraOptions_1000
5355     * @tc.name  : testNetworkMgrSocketTCPSocketSetExtraOptions1000
5356     * @tc.desc  : Get TCPSocket status,Input parameter TCPNoDelay is false;  callback
5357     * @tc.size  : MediumTest
5358     * @tc.type  : Function
5359     * @tc.level : level 2
5360     */
5361    it('testNetworkMgrSocketTCPSocketSetExtraOptions1000', 0, async (done: Function) => {
5362      let caseName: string = 'testNetworkMgrSocketTCPSocketSetExtraOptions1000';
5363      try {
5364        console.info(`${caseName} test start`);
5365        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
5366        expect(tcp).assertInstanceOf('Object');
5367        let bindAddress: socket.NetAddress = {
5368          address: '127.0.0.1',
5369          port: 9005
5370        };
5371        await tcp.bind(bindAddress);
5372        let tcpExtraOptions: socket.TCPExtraOptions = {
5373          TCPNoDelay: false,
5374          socketLinger: {
5375            on: true, linger: 10
5376          }
5377        };
5378        tcp.setExtraOptions(tcpExtraOptions, async (err: BusinessError) => {
5379          if (err) {
5380            console.info(`${caseName} fail err:${JSON.stringify(err)}`);
5381            expectFail();
5382          } else {
5383            console.info(`${caseName} success`);
5384            expectSuccess();
5385          }
5386          await tcp.close();
5387          console.info(`${caseName} test end`);
5388          done();
5389        });
5390      } catch (err) {
5391        console.info(`${caseName}_catch fail err:${JSON.stringify(err)}`);
5392        expectFail();
5393        console.info(`${caseName} test end`);
5394        done();
5395      }
5396    });
5397
5398    /* *
5399     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_SetExtraOptions_1100
5400     * @tc.name  : testNetworkMgrSocketTCPSocketSetExtraOptions1100
5401     * @tc.desc  : Get TCPSocket status,Input parameter TCPNoDelay is true;  callback
5402     * @tc.size  : MediumTest
5403     * @tc.type  : Function
5404     * @tc.level : level 2
5405     */
5406    it('testNetworkMgrSocketTCPSocketSetExtraOptions1100', 0, async (done: Function) => {
5407      let caseName: string = 'testNetworkMgrSocketTCPSocketSetExtraOptions1100';
5408      try {
5409        console.info(`${caseName} test start`);
5410        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
5411        expect(tcp).assertInstanceOf('Object');
5412        let bindAddress: socket.NetAddress = {
5413          address: '127.0.0.1',
5414          port: 9006
5415        };
5416        await tcp.bind(bindAddress);
5417        let tcpExtraOptions: socket.TCPExtraOptions = {
5418          TCPNoDelay: true,
5419          socketLinger: {
5420            on: true, linger: 10
5421          }
5422        };
5423        tcp.setExtraOptions(tcpExtraOptions, async (err: BusinessError) => {
5424          if (err) {
5425            console.info(`${caseName} fail err:${JSON.stringify(err)}`);
5426            expectFail();
5427          } else {
5428            console.info(`${caseName} success`);
5429            expectSuccess();
5430          }
5431          await tcp.close();
5432          console.info(`${caseName} test end`);
5433          done();
5434        });
5435      } catch (err) {
5436        console.info(`${caseName}_catch fail err:${JSON.stringify(err)}`);
5437        expectFail();
5438        console.info(`${caseName} test end`);
5439        done();
5440      }
5441    });
5442
5443    /* *
5444     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_SetExtraOptions_1200
5445     * @tc.name  : testNetworkMgrSocketTCPSocketSetExtraOptions1200
5446     * @tc.desc  : Get TCPSocket status,Input parameter receiveBufferSize is -1; callback
5447     * @tc.size  : MediumTest
5448     * @tc.type  : Function
5449     * @tc.level : level 2
5450     */
5451    it('testNetworkMgrSocketTCPSocketSetExtraOptions1200', 0, async (done: Function) => {
5452      let caseName: string = 'testNetworkMgrSocketTCPSocketSetExtraOptions1200';
5453      try {
5454        console.info(`${caseName} test start`);
5455        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
5456        expect(tcp).assertInstanceOf('Object');
5457        let bindAddress: socket.NetAddress = {
5458          address: '127.0.0.1',
5459          port: 9007
5460        };
5461        await tcp.bind(bindAddress);
5462        let tcpExtraOptions: socket.TCPExtraOptions = {
5463          receiveBufferSize: -1,
5464          socketLinger: {
5465            on: true, linger: 10
5466          }
5467        };
5468        tcp.setExtraOptions(tcpExtraOptions, async (err: BusinessError) => {
5469          if (err) {
5470            console.info(`${caseName} fail err:${JSON.stringify(err)}`);
5471            expectFail();
5472          } else {
5473            console.info(`${caseName} success`);
5474            expectSuccess();
5475          }
5476          await tcp.close();
5477          console.info(`${caseName} test end`);
5478          done();
5479        });
5480      } catch (err) {
5481        console.info(`${caseName}_catch fail err:${JSON.stringify(err)}`);
5482        expectFail();
5483        console.info(`${caseName} test end`);
5484        done();
5485      }
5486    });
5487
5488    /* *
5489     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_SetExtraOptions_1300
5490     * @tc.name  : testNetworkMgrSocketTCPSocketSetExtraOptions1300
5491     * @tc.desc  : Get TCPSocket status,Input parameter receiveBufferSize is 0; callback
5492     * @tc.size  : MediumTest
5493     * @tc.type  : Function
5494     * @tc.level : level 2
5495     */
5496    it('testNetworkMgrSocketTCPSocketSetExtraOptions1300', 0, async (done: Function) => {
5497      let caseName: string = 'testNetworkMgrSocketTCPSocketSetExtraOptions1300';
5498      try {
5499        console.info(`${caseName} test start`);
5500        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
5501        expect(tcp).assertInstanceOf('Object');
5502        let bindAddress: socket.NetAddress = {
5503          address: '127.0.0.1',
5504          port: 9008
5505        };
5506        await tcp.bind(bindAddress);
5507        let tcpExtraOptions: socket.TCPExtraOptions = {
5508          receiveBufferSize: 0,
5509          socketLinger: {
5510            on: true, linger: 10
5511          }
5512        };
5513        tcp.setExtraOptions(tcpExtraOptions, async (err: BusinessError) => {
5514          if (err) {
5515            console.info(`${caseName} fail err:${JSON.stringify(err)}`);
5516            expectFail();
5517          } else {
5518            console.info(`${caseName} success`);
5519            expectSuccess();
5520          }
5521          await tcp.close();
5522          console.info(`${caseName} test end`);
5523          done();
5524        });
5525      } catch (err) {
5526        console.info(`${caseName}_catch fail err:${JSON.stringify(err)}`);
5527        expectFail();
5528        console.info(`${caseName} test end`);
5529        done();
5530      }
5531    });
5532
5533    /* *
5534     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_SetExtraOptions_1400
5535     * @tc.name  : testNetworkMgrSocketTCPSocketSetExtraOptions1400
5536     * @tc.desc  : Get TCPSocket status,Input parameter receiveBufferSize is 100; callback
5537     * @tc.size  : MediumTest
5538     * @tc.type  : Function
5539     * @tc.level : level 2
5540     */
5541    it('testNetworkMgrSocketTCPSocketSetExtraOptions1400', 0, async (done: Function) => {
5542      let caseName: string = 'testNetworkMgrSocketTCPSocketSetExtraOptions1400';
5543      try {
5544        console.info(`${caseName} test start`);
5545        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
5546        expect(tcp).assertInstanceOf('Object');
5547        let bindAddress: socket.NetAddress = {
5548          address: '127.0.0.1',
5549          port: 9009
5550        };
5551        await tcp.bind(bindAddress);
5552        let tcpExtraOptions: socket.TCPExtraOptions = {
5553          receiveBufferSize: 100,
5554          socketLinger: {
5555            on: true, linger: 10
5556          }
5557        };
5558        tcp.setExtraOptions(tcpExtraOptions, async (err: BusinessError) => {
5559          if (err) {
5560            console.info(`${caseName} fail err:${JSON.stringify(err)}`);
5561            expectFail();
5562          } else {
5563            console.info(`${caseName} success`);
5564            expectSuccess();
5565          }
5566          await tcp.close();
5567          console.info(`${caseName} test end`);
5568          done();
5569        });
5570      } catch (err) {
5571        console.info(`${caseName}_catch fail err:${JSON.stringify(err)}`);
5572        expectFail();
5573        console.info(`${caseName} test end`);
5574        done();
5575      }
5576    });
5577
5578    /* *
5579     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_SetExtraOptions_1500
5580     * @tc.name  : testNetworkMgrSocketTCPSocketSetExtraOptions1500
5581     * @tc.desc  : Get TCPSocket status,Input parameter sendBufferSize is -1; callback
5582     * @tc.size  : MediumTest
5583     * @tc.type  : Function
5584     * @tc.level : level 2
5585     */
5586    it('testNetworkMgrSocketTCPSocketSetExtraOptions1500', 0, async (done: Function) => {
5587      let caseName: string = 'testNetworkMgrSocketTCPSocketSetExtraOptions1500';
5588      try {
5589        console.info(`${caseName} test start`);
5590        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
5591        expect(tcp).assertInstanceOf('Object');
5592        let bindAddress: socket.NetAddress = {
5593          address: '127.0.0.1',
5594          port: 9010
5595        };
5596        await tcp.bind(bindAddress);
5597        let tcpExtraOptions: socket.TCPExtraOptions = {
5598          sendBufferSize: -1,
5599          socketLinger: {
5600            on: true, linger: 10
5601          }
5602        };
5603        tcp.setExtraOptions(tcpExtraOptions, async (err: BusinessError) => {
5604          if (err) {
5605            console.info(`${caseName} fail err:${JSON.stringify(err)}`);
5606            expectFail();
5607          } else {
5608            console.info(`${caseName} success`);
5609            expectSuccess();
5610          }
5611          await tcp.close();
5612          console.info(`${caseName} test end`);
5613          done();
5614        });
5615      } catch (err) {
5616        console.info(`${caseName}_catch fail err:${JSON.stringify(err)}`);
5617        expectFail();
5618        console.info(`${caseName} test end`);
5619        done();
5620      }
5621    });
5622
5623    /* *
5624     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_SetExtraOptions_1600
5625     * @tc.name  : testNetworkMgrSocketTCPSocketSetExtraOptions1600
5626     * @tc.desc  : Get TCPSocket status,Input parameter sendBufferSize is 0; callback
5627     * @tc.size  : MediumTest
5628     * @tc.type  : Function
5629     * @tc.level : level 2
5630     */
5631    it('testNetworkMgrSocketTCPSocketSetExtraOptions1600', 0, async (done: Function) => {
5632      let caseName: string = 'testNetworkMgrSocketTCPSocketSetExtraOptions1600';
5633      try {
5634        console.info(`${caseName} test start`);
5635        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
5636        expect(tcp).assertInstanceOf('Object');
5637        let bindAddress: socket.NetAddress = {
5638          address: '127.0.0.1',
5639          port: 9011
5640        };
5641        await tcp.bind(bindAddress);
5642        let tcpExtraOptions: socket.TCPExtraOptions = {
5643          sendBufferSize: 0,
5644          socketLinger: {
5645            on: true, linger: 10
5646          }
5647        };
5648        tcp.setExtraOptions(tcpExtraOptions, async (err: BusinessError) => {
5649          if (err) {
5650            console.info(`${caseName} fail err:${JSON.stringify(err)}`);
5651            expectFail();
5652          } else {
5653            console.info(`${caseName} success`);
5654            expectSuccess();
5655          }
5656          await tcp.close();
5657          console.info(`${caseName} test end`);
5658          done();
5659        });
5660      } catch (err) {
5661        console.info(`${caseName}_catch fail err:${JSON.stringify(err)}`);
5662        expectFail();
5663        console.info(`${caseName} test end`);
5664        done();
5665      }
5666    });
5667
5668    /* *
5669     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_SetExtraOptions_1700
5670     * @tc.name  : testNetworkMgrSocketTCPSocketSetExtraOptions1700
5671     * @tc.desc  : Get TCPSocket status,Input parameter sendBufferSize is 100; callback
5672     * @tc.size  : MediumTest
5673     * @tc.type  : Function
5674     * @tc.level : level 2
5675     */
5676    it('testNetworkMgrSocketTCPSocketSetExtraOptions1700', 0, async (done: Function) => {
5677      let caseName: string = 'testNetworkMgrSocketTCPSocketSetExtraOptions1700';
5678      try {
5679        console.info(`${caseName} test start`);
5680        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
5681        expect(tcp).assertInstanceOf('Object');
5682        let bindAddress: socket.NetAddress = {
5683          address: '127.0.0.1',
5684          port: 9012
5685        };
5686        await tcp.bind(bindAddress);
5687        let tcpExtraOptions: socket.TCPExtraOptions = {
5688          sendBufferSize: 100,
5689          socketLinger: {
5690            on: true, linger: 10
5691          }
5692        };
5693        tcp.setExtraOptions(tcpExtraOptions, async (err: BusinessError) => {
5694          if (err) {
5695            console.info(`${caseName} fail err:${JSON.stringify(err)}`);
5696            expectFail();
5697          } else {
5698            console.info(`${caseName} success`);
5699            expectSuccess();
5700          }
5701          await tcp.close();
5702          console.info(`${caseName} test end`);
5703          done();
5704        });
5705      } catch (err) {
5706        console.info(`${caseName}_catch fail err:${JSON.stringify(err)}`);
5707        expectFail();
5708        console.info(`${caseName} test end`);
5709        done();
5710      }
5711    });
5712
5713    /* *
5714     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_SetExtraOptions_1800
5715     * @tc.name  : testNetworkMgrSocketTCPSocketSetExtraOptions1800
5716     * @tc.desc  : Get TCPSocket status,Input parameter reuseAddress is true; callback
5717     * @tc.size  : MediumTest
5718     * @tc.type  : Function
5719     * @tc.level : level 2
5720     */
5721    it('testNetworkMgrSocketTCPSocketSetExtraOptions1800', 0, async (done: Function) => {
5722      let caseName: string = 'testNetworkMgrSocketTCPSocketSetExtraOptions1800';
5723      try {
5724        console.info(`${caseName} test start`);
5725        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
5726        expect(tcp).assertInstanceOf('Object');
5727        let bindAddress: socket.NetAddress = {
5728          address: '127.0.0.1',
5729          port: 9013
5730        };
5731        await tcp.bind(bindAddress);
5732        let tcpExtraOptions: socket.TCPExtraOptions = {
5733          reuseAddress: true,
5734          socketLinger: {
5735            on: true, linger: 10
5736          }
5737        };
5738        tcp.setExtraOptions(tcpExtraOptions, async (err: BusinessError) => {
5739          if (err) {
5740            console.info(`${caseName} fail err:${JSON.stringify(err)}`);
5741            expectFail();
5742          } else {
5743            console.info(`${caseName} success`);
5744            expectSuccess();
5745          }
5746          await tcp.close();
5747          console.info(`${caseName} test end`);
5748          done();
5749        });
5750      } catch (err) {
5751        console.info(`${caseName}_catch fail err:${JSON.stringify(err)}`);
5752        expectFail();
5753        console.info(`${caseName} test end`);
5754        done();
5755      }
5756    });
5757
5758    /* *
5759     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_SetExtraOptions_1900
5760     * @tc.name  : testNetworkMgrSocketTCPSocketSetExtraOptions1900
5761     * @tc.desc  : Get TCPSocket status,Input parameter reuseAddress is false; callback
5762     * @tc.size  : MediumTest
5763     * @tc.type  : Function
5764     * @tc.level : level 2
5765     */
5766    it('testNetworkMgrSocketTCPSocketSetExtraOptions1900', 0, async (done: Function) => {
5767      let caseName: string = 'testNetworkMgrSocketTCPSocketSetExtraOptions1900';
5768      try {
5769        console.info(`${caseName} test start`);
5770        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
5771        expect(tcp).assertInstanceOf('Object');
5772        let bindAddress: socket.NetAddress = {
5773          address: '127.0.0.1',
5774          port: 9014
5775        };
5776        await tcp.bind(bindAddress);
5777        let tcpExtraOptions: socket.TCPExtraOptions = {
5778          reuseAddress: false,
5779          socketLinger: {
5780            on: true, linger: 10
5781          }
5782        };
5783        tcp.setExtraOptions(tcpExtraOptions, async (err: BusinessError) => {
5784          if (err) {
5785            console.info(`${caseName} fail err:${JSON.stringify(err)}`);
5786            expectFail();
5787          } else {
5788            console.info(`${caseName} success`);
5789            expectSuccess();
5790          }
5791          await tcp.close();
5792          console.info(`${caseName} test end`);
5793          done();
5794        });
5795      } catch (err) {
5796        console.info(`${caseName}_catch fail err:${JSON.stringify(err)}`);
5797        expectFail();
5798        console.info(`${caseName} test end`);
5799        done();
5800      }
5801    });
5802
5803    /* *
5804     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_SetExtraOptions_2000
5805     * @tc.name  : testNetworkMgrSocketTCPSocketSetExtraOptions2000
5806     * @tc.desc  : Get TCPSocket status,Input parameter socketTimeout is -1; callback
5807     * @tc.size  : MediumTest
5808     * @tc.type  : Function
5809     * @tc.level : level 2
5810     */
5811    it('testNetworkMgrSocketTCPSocketSetExtraOptions2000', 0, async (done: Function) => {
5812      let caseName: string = 'testNetworkMgrSocketTCPSocketSetExtraOptions2000';
5813      try {
5814        console.info(`${caseName} test start`);
5815        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
5816        expect(tcp).assertInstanceOf('Object');
5817        let bindAddress: socket.NetAddress = {
5818          address: '127.0.0.1',
5819          port: 9014
5820        };
5821        await tcp.bind(bindAddress);
5822        let tcpExtraOptions: socket.TCPExtraOptions = {
5823          socketTimeout: -1,
5824          socketLinger: {
5825            on: true, linger: 10
5826          }
5827        };
5828        tcp.setExtraOptions(tcpExtraOptions, async (err: BusinessError) => {
5829          if (err) {
5830            console.info(`${caseName} fail err:${JSON.stringify(err)}`);
5831            expectTrue(err.code===2301033);
5832          } else {
5833            console.info(`${caseName} success`);
5834            expectFail();
5835          }
5836          await tcp.close();
5837          console.info(`${caseName} test end`);
5838          done();
5839        });
5840      } catch (err) {
5841        console.info(`${caseName}_catch fail err:${JSON.stringify(err)}`);
5842        expectFail();
5843        console.info(`${caseName} test end`);
5844        done();
5845      }
5846    });
5847
5848    /* *
5849     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_SetExtraOptions_2100
5850     * @tc.name  : testNetworkMgrSocketTCPSocketSetExtraOptions2100
5851     * @tc.desc  : Get TCPSocket status,Input parameter socketTimeout is 0; callback
5852     * @tc.size  : MediumTest
5853     * @tc.type  : Function
5854     * @tc.level : level 2
5855     */
5856    it('testNetworkMgrSocketTCPSocketSetExtraOptions2100', 0, async (done: Function) => {
5857      let caseName: string = 'testNetworkMgrSocketTCPSocketSetExtraOptions2100';
5858      try {
5859        console.info(`${caseName} test start`);
5860        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
5861        expect(tcp).assertInstanceOf('Object');
5862        let bindAddress: socket.NetAddress = {
5863          address: '127.0.0.1',
5864          port: 9014
5865        };
5866        await tcp.bind(bindAddress);
5867        let tcpExtraOptions: socket.TCPExtraOptions = {
5868          socketTimeout: 0,
5869          socketLinger: {
5870            on: true, linger: 10
5871          }
5872        };
5873        tcp.setExtraOptions(tcpExtraOptions, async (err: BusinessError) => {
5874          if (err) {
5875            console.info(`${caseName} fail err:${JSON.stringify(err)}`);
5876            expectFail();
5877          } else {
5878            console.info(`${caseName} success`);
5879            expectSuccess();
5880          }
5881          await tcp.close();
5882          console.info(`${caseName} test end`);
5883          done();
5884        });
5885      } catch (err) {
5886        console.info(`${caseName}_catch fail err:${JSON.stringify(err)}`);
5887        expectFail();
5888        console.info(`${caseName} test end`);
5889        done();
5890      }
5891    });
5892
5893    /* *
5894     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_SetExtraOptions_2200
5895     * @tc.name  : testNetworkMgrSocketTCPSocketSetExtraOptions2200
5896     * @tc.desc  : Get TCPSocket status,Input parameter socketTimeout is 100; callback
5897     * @tc.size  : MediumTest
5898     * @tc.type  : Function
5899     * @tc.level : level 2
5900     */
5901    it('testNetworkMgrSocketTCPSocketSetExtraOptions2200', 0, async (done: Function) => {
5902      let caseName: string = 'testNetworkMgrSocketTCPSocketSetExtraOptions2200';
5903      try {
5904        console.info(`${caseName} test start`);
5905        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
5906        expect(tcp).assertInstanceOf('Object');
5907        let bindAddress: socket.NetAddress = {
5908          address: '127.0.0.1',
5909          port: 9015
5910        };
5911        await tcp.bind(bindAddress);
5912        let tcpExtraOptions: socket.TCPExtraOptions = {
5913          socketTimeout: 100,
5914          socketLinger: {
5915            on: true, linger: 10
5916          }
5917        };
5918        tcp.setExtraOptions(tcpExtraOptions, async (err: BusinessError) => {
5919          if (err) {
5920            console.info(`${caseName} fail err:${JSON.stringify(err)}`);
5921            expectFail();
5922          } else {
5923            console.info(`${caseName} success`);
5924            expectSuccess();
5925          }
5926          await tcp.close();
5927          console.info(`${caseName} test end`);
5928          done();
5929        });
5930      } catch (err) {
5931        console.info(`${caseName}_catch fail err:${JSON.stringify(err)}`);
5932        expectFail();
5933        console.info(`${caseName} test end`);
5934        done();
5935      }
5936    });
5937
5938    /* *
5939     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_SetExtraOptions_2300
5940     * @tc.name  : testNetworkMgrSocketTCPSocketSetExtraOptions2300
5941     * @tc.desc  : Get TCPSocket status,Input parameter linger is -1; callback
5942     * @tc.size  : MediumTest
5943     * @tc.type  : Function
5944     * @tc.level : level 2
5945     */
5946    it('testNetworkMgrSocketTCPSocketSetExtraOptions2300', 0, async (done: Function) => {
5947      let caseName: string = 'testNetworkMgrSocketTCPSocketSetExtraOptions2300';
5948      try {
5949        console.info(`${caseName} test start`);
5950        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
5951        expect(tcp).assertInstanceOf('Object');
5952        let bindAddress: socket.NetAddress = {
5953          address: '127.0.0.1',
5954          port: 9016
5955        };
5956        await tcp.bind(bindAddress);
5957        let tcpExtraOptions: socket.TCPExtraOptions = {
5958          socketLinger: {
5959            on: true, linger:-1
5960          }
5961        };
5962        tcp.setExtraOptions(tcpExtraOptions, async (err: BusinessError) => {
5963          if (err) {
5964            console.info(`${caseName} fail err:${JSON.stringify(err)}`);
5965            expectFail();
5966          } else {
5967            console.info(`${caseName} success`);
5968            expectSuccess();
5969          }
5970          await tcp.close();
5971          console.info(`${caseName} test end`);
5972          done();
5973        });
5974      } catch (err) {
5975        console.info(`${caseName}_catch fail err:${JSON.stringify(err)}`);
5976        expectFail();
5977        console.info(`${caseName} test end`);
5978        done();
5979      }
5980    });
5981
5982    /* *
5983     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_SetExtraOptions_2400
5984     * @tc.name  : testNetworkMgrSocketTCPSocketSetExtraOptions2400
5985     * @tc.desc  : Get TCPSocket status,Input parameter linger is 0; callback
5986     * @tc.size  : MediumTest
5987     * @tc.type  : Function
5988     * @tc.level : level 2
5989     */
5990    it('testNetworkMgrSocketTCPSocketSetExtraOptions2400', 0, async (done: Function) => {
5991      let caseName: string = 'testNetworkMgrSocketTCPSocketSetExtraOptions2400';
5992      try {
5993        console.info(`${caseName} test start`);
5994        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
5995        expect(tcp).assertInstanceOf('Object');
5996        let bindAddress: socket.NetAddress = {
5997          address: '127.0.0.1',
5998          port: 9017
5999        };
6000        await tcp.bind(bindAddress);
6001        let tcpExtraOptions: socket.TCPExtraOptions = {
6002          socketLinger: {
6003            on: true, linger:0
6004          }
6005        };
6006        tcp.setExtraOptions(tcpExtraOptions, async (err: BusinessError) => {
6007          if (err) {
6008            console.info(`${caseName} fail err:${JSON.stringify(err)}`);
6009            expectFail();
6010          } else {
6011            console.info(`${caseName} success`);
6012            expectSuccess();
6013          }
6014          await tcp.close();
6015          console.info(`${caseName} test end`);
6016          done();
6017        });
6018      } catch (err) {
6019        console.info(`${caseName}_catch fail err:${JSON.stringify(err)}`);
6020        expectFail();
6021        console.info(`${caseName} test end`);
6022        done();
6023      }
6024    });
6025
6026    /* *
6027     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_SetExtraOptions_2500
6028     * @tc.name  : testNetworkMgrSocketTCPSocketSetExtraOptions2500
6029     * @tc.desc  : Get TCPSocket status,Input parameter linger is 65535; callback
6030     * @tc.size  : MediumTest
6031     * @tc.type  : Function
6032     * @tc.level : level 2
6033     */
6034    it('testNetworkMgrSocketTCPSocketSetExtraOptions2500', 0, async (done: Function) => {
6035      let caseName: string = 'testNetworkMgrSocketTCPSocketSetExtraOptions2500';
6036      try {
6037        console.info(`${caseName} test start`);
6038        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
6039        expect(tcp).assertInstanceOf('Object');
6040        let bindAddress: socket.NetAddress = {
6041          address: '127.0.0.1',
6042          port: 9018
6043        };
6044        await tcp.bind(bindAddress);
6045        let tcpExtraOptions: socket.TCPExtraOptions = {
6046          socketLinger: {
6047            on: true, linger:65535
6048          }
6049        };
6050        tcp.setExtraOptions(tcpExtraOptions, async (err: BusinessError) => {
6051          if (err) {
6052            console.info(`${caseName} fail err:${JSON.stringify(err)}`);
6053            expectFail();
6054          } else {
6055            console.info(`${caseName} success`);
6056            expectSuccess();
6057          }
6058          await tcp.close();
6059          console.info(`${caseName} test end`);
6060          done();
6061        });
6062      } catch (err) {
6063        console.info(`${caseName}_catch fail err:${JSON.stringify(err)}`);
6064        expectFail();
6065        console.info(`${caseName} test end`);
6066        done();
6067      }
6068    });
6069
6070    /* *
6071     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_SetExtraOptions_2600
6072     * @tc.name  : testNetworkMgrSocketTCPSocketSetExtraOptions2600
6073     * @tc.desc  : Get TCPSocket status,Input parameter linger is 65536; callback
6074     * @tc.size  : MediumTest
6075     * @tc.type  : Function
6076     * @tc.level : level 2
6077     */
6078    it('testNetworkMgrSocketTCPSocketSetExtraOptions2600', 0, async (done: Function) => {
6079      let caseName: string = 'testNetworkMgrSocketTCPSocketSetExtraOptions2600';
6080      try {
6081        console.info(`${caseName} test start`);
6082        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
6083        expect(tcp).assertInstanceOf('Object');
6084        let bindAddress: socket.NetAddress = {
6085          address: '127.0.0.1',
6086          port: 9019
6087        };
6088        await tcp.bind(bindAddress);
6089        let tcpExtraOptions: socket.TCPExtraOptions = {
6090          socketLinger: {
6091            on: true, linger:65536
6092          }
6093        };
6094        tcp.setExtraOptions(tcpExtraOptions, async (err: BusinessError) => {
6095          if (err) {
6096            console.info(`${caseName} fail err:${JSON.stringify(err)}`);
6097            expectFail();
6098          } else {
6099            console.info(`${caseName} success`);
6100            expectSuccess();
6101          }
6102          await tcp.close();
6103          console.info(`${caseName} test end`);
6104          done();
6105        });
6106      } catch (err) {
6107        console.info(`${caseName}_catch fail err:${JSON.stringify(err)}`);
6108        expectFail();
6109        console.info(`${caseName} test end`);
6110        done();
6111      }
6112    });
6113
6114    /* *
6115     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_SetExtraOptions_2700
6116     * @tc.name  : testNetworkMgrSocketTCPSocketSetExtraOptions2700
6117     * @tc.desc  : Get TCPSocket status,after bind; promise
6118     * @tc.size  : MediumTest
6119     * @tc.type  : Function
6120     * @tc.level : level 2
6121     */
6122    it('testNetworkMgrSocketTCPSocketSetExtraOptions2700', 0, async (done: Function) => {
6123      let caseName: string = 'testNetworkMgrSocketTCPSocketSetExtraOptions2700';
6124      console.info(`${caseName} test start`);
6125      try {
6126        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
6127        expect(tcp).assertInstanceOf('Object')
6128        let bindAddress: socket.NetAddress = {
6129          address: '127.0.0.1',
6130          port: 9004
6131        };
6132        await tcp.bind(bindAddress);
6133        let tcpExtraOptions: socket.TCPExtraOptions = {
6134          keepAlive: true,
6135          OOBInline: true,
6136          TCPNoDelay: true,
6137          socketLinger: {
6138            on: true, linger: 10
6139          },
6140          receiveBufferSize: 1000,
6141          sendBufferSize: 1000,
6142          reuseAddress: true,
6143          socketTimeout: 3000
6144        };
6145        tcp.setExtraOptions(tcpExtraOptions).then(() => {
6146          console.info(`${caseName} success `);
6147          expectSuccess();
6148          done();
6149        }).catch((err: BusinessError) => {
6150          console.info(`${caseName} fail err:${JSON.stringify(err)}`);
6151          expectFail();
6152          done();
6153        }).finally(async () => {
6154          await tcp.close();
6155          console.info(`${caseName} test end`);
6156          done();
6157        });
6158      } catch (err) {
6159        console.info(`${caseName}_catch fail ${JSON.stringify(err)}`);
6160        expectFail();
6161        console.info(`${caseName} test end`);
6162        done();
6163      }
6164    });
6165
6166    /* *
6167     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_SetExtraOptions_2800
6168     * @tc.name  : testNetworkMgrSocketTCPSocketSetExtraOptions2800
6169     * @tc.desc  : Get TCPSocket status,after bind and connect; promise
6170     * @tc.size  : MediumTest
6171     * @tc.type  : Function
6172     * @tc.level : level 2
6173     */
6174    it('testNetworkMgrSocketTCPSocketSetExtraOptions2800', 0, async (done: Function) => {
6175      let caseName: String = 'testNetworkMgrSocketTCPSocketSetExtraOptions2800';
6176      try {
6177        console.info(`${caseName} test start`);
6178        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
6179        expect(tcp).assertInstanceOf('Object');
6180        let bindAddress: socket.NetAddress = {
6181          address: '127.0.0.1',
6182          port: 4088
6183        };
6184        await tcp.bind(bindAddress);
6185        let tcpConnectOptions: socket.TCPConnectOptions = {
6186          address: bindAddress,
6187        };
6188        await tcp.connect(tcpConnectOptions);
6189        let tcpExtraOptions: socket.TCPExtraOptions = {
6190          keepAlive: true,
6191          OOBInline: true,
6192          TCPNoDelay: true,
6193          socketLinger: {
6194            on: true, linger: 10
6195          },
6196          receiveBufferSize: 1000,
6197          sendBufferSize: 1000,
6198          reuseAddress: true,
6199          socketTimeout: 3000
6200        };
6201        tcp.setExtraOptions(tcpExtraOptions).then(() => {
6202          console.info(`${caseName} success `);
6203          expectSuccess();
6204          done();
6205        }).catch((err: BusinessError) => {
6206          console.info(`${caseName}_1 fail err:${JSON.stringify(err)}`);
6207          expectFail();
6208          done();
6209        }).finally(async () => {
6210          await tcp.close();
6211          console.info(`${caseName} test end`);
6212          done();
6213        })
6214      } catch (err) {
6215        console.info(`${caseName}_catch fail err:${JSON.stringify(err)}`);
6216        expectFail();
6217        console.info(`${caseName} test end`);
6218        done();
6219      }
6220    });
6221
6222    /* *
6223     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_SetExtraOptions_2900
6224     * @tc.name  : testNetworkMgrSocketTCPSocketSetExtraOptions2900
6225     * @tc.desc  : Get TCPSocket status,after listen and connect; promise
6226     * @tc.size  : MediumTest
6227     * @tc.type  : Function
6228     * @tc.level : level 2
6229     */
6230    it('testNetworkMgrSocketTCPSocketSetExtraOptions2900', 0, async (done: Function) => {
6231      let caseName: String = 'testNetworkMgrSocketTCPSocketSetExtraOptions2900';
6232      try {
6233        console.info(`${caseName} test start`);
6234        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
6235        expect(tcp).assertInstanceOf('Object');
6236        let tcpServer: socket.TCPSocketServer = socket.constructTCPSocketServerInstance();
6237        expect(tcpServer).assertInstanceOf('Object');
6238        let listenAddress: socket.NetAddress = {
6239          address: '127.0.0.1',
6240          port: 4089,
6241          family: 1
6242        };
6243        await tcpServer.listen(listenAddress);
6244        let tcpConnectOptions: socket.TCPConnectOptions = {
6245          address: listenAddress,
6246        };
6247        await tcp.connect(tcpConnectOptions);
6248        let tcpExtraOptions: socket.TCPExtraOptions = {
6249          keepAlive: true,
6250          OOBInline: true,
6251          TCPNoDelay: true,
6252          socketLinger: {
6253            on: true, linger: 10
6254          },
6255          receiveBufferSize: 1000,
6256          sendBufferSize: 1000,
6257          reuseAddress: true,
6258          socketTimeout: 3000
6259        };
6260        tcp.setExtraOptions(tcpExtraOptions).then(() => {
6261          console.info(`${caseName} success `);
6262          expectSuccess();
6263          done();
6264        }).catch((err: BusinessError) => {
6265          console.info(`${caseName} fail err:${JSON.stringify(err)}`);
6266          expectFail();
6267          done();
6268        }).finally(async () => {
6269          await tcp.close();
6270          console.info(`${caseName} test end`);
6271          done();
6272        });
6273      } catch (err) {
6274        console.info(`${caseName}_catch fail err:${JSON.stringify(err)}`);
6275        expectFail();
6276        console.info(`${caseName} test end`);
6277        done();
6278      }
6279    });
6280
6281    /* *
6282     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_SetExtraOptions_3000
6283     * @tc.name  : testNetworkMgrSocketTCPSocketSetExtraOptions3000
6284     * @tc.desc  : Get TCPSocket status,Input parameter is null; promise
6285     * @tc.size  : MediumTest
6286     * @tc.type  : Function
6287     * @tc.level : level 2
6288     */
6289    it('testNetworkMgrSocketTCPSocketSetExtraOptions3000', 0, async (done: Function) => {
6290      let caseName: string = 'testNetworkMgrSocketTCPSocketSetExtraOptions3000';
6291      console.info(`${caseName} test start`);
6292      try {
6293        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
6294        expect(tcp).assertInstanceOf('Object');
6295        let bindAddress: socket.NetAddress = {
6296          address: '127.0.0.1',
6297          port: 4090
6298        };
6299        await tcp.bind(bindAddress);
6300        tcp.setExtraOptions(null).then(() => {
6301          console.info(`${caseName} success `);
6302          expectFail();
6303          done();
6304        }).catch((err: BusinessError) => {
6305          console.info(`${caseName} fail err:${JSON.stringify(err)}`);
6306          expectEqual(err.code, 401);
6307          done();
6308        }).finally(async () => {
6309          await tcp.close();
6310          console.info(`${caseName} test end`);
6311          done();
6312        });
6313      } catch (err) {
6314        console.info(`${caseName}_catch fail ${JSON.stringify(err)}`);
6315        expectFail();
6316        console.info(`${caseName} test end`);
6317        done();
6318      }
6319    });
6320
6321    /* *
6322     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_SetExtraOptions_3100
6323     * @tc.name  : testNetworkMgrSocketTCPSocketSetExtraOptions3100
6324     * @tc.desc  : Get TCPSocket status,Input parameter is undefined; promise
6325     * @tc.size  : MediumTest
6326     * @tc.type  : Function
6327     * @tc.level : level 2
6328     */
6329    it('testNetworkMgrSocketTCPSocketSetExtraOptions3100', 0, async (done: Function) => {
6330      let caseName: string = 'testNetworkMgrSocketTCPSocketSetExtraOptions3100';
6331      console.info(`${caseName} test start`);
6332      try {
6333        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
6334        expect(tcp).assertInstanceOf('Object');
6335        let bindAddress: socket.NetAddress = {
6336          address: '127.0.0.1',
6337          port: 4091
6338        };
6339        await tcp.bind(bindAddress);
6340        tcp.setExtraOptions(undefined).then(() => {
6341          console.info(`${caseName} success `);
6342          expectFail();
6343          done();
6344        }).catch((err: BusinessError) => {
6345          console.info(`${caseName} fail err:${JSON.stringify(err)}`);
6346          expectEqual(err.code, 401);
6347          done();
6348        }).finally(async () => {
6349          await tcp.close();
6350          console.info(`${caseName} test end`);
6351          done();
6352        });
6353      } catch (err) {
6354        console.info(`${caseName}_catch fail ${JSON.stringify(err)}`);
6355        expectFail();
6356        console.info(`${caseName} test end`);
6357        done();
6358      }
6359    });
6360
6361    /* *
6362     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_SetExtraOptions_3200
6363     * @tc.name  : testNetworkMgrSocketTCPSocketSetExtraOptions3200
6364     * @tc.desc  : Get TCPSocket status,Input parameter keepAlive is false; promise
6365     * @tc.size  : MediumTest
6366     * @tc.type  : Function
6367     * @tc.level : level 2
6368     */
6369    it('testNetworkMgrSocketTCPSocketSetExtraOptions3200', 0, async (done: Function) => {
6370      let caseName: string = 'testNetworkMgrSocketTCPSocketSetExtraOptions3200';
6371      console.info(`${caseName} test start`);
6372      try {
6373        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
6374        expect(tcp).assertInstanceOf('Object')
6375        let bindAddress: socket.NetAddress = {
6376          address: '127.0.0.1',
6377          port: 10001
6378        };
6379        await tcp.bind(bindAddress);
6380        let tcpExtraOptions: socket.TCPExtraOptions = {
6381          keepAlive: true,
6382          socketLinger: {
6383            on: true, linger: 10
6384          },
6385        };
6386        tcp.setExtraOptions(tcpExtraOptions).then(() => {
6387          console.info(`${caseName} success `);
6388          expectSuccess();
6389          done();
6390        }).catch((err: BusinessError) => {
6391          console.info(`${caseName} fail err:${JSON.stringify(err)}`);
6392          expectFail();
6393          done();
6394        }).finally(async () => {
6395          await tcp.close();
6396          console.info(`${caseName} test end`);
6397          done();
6398        });
6399      } catch (err) {
6400        console.info(`${caseName}_catch fail ${JSON.stringify(err)}`);
6401        expectFail();
6402        console.info(`${caseName} test end`);
6403        done();
6404      }
6405    });
6406
6407    /* *
6408     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_SetExtraOptions_3300
6409     * @tc.name  : testNetworkMgrSocketTCPSocketSetExtraOptions3300
6410     * @tc.desc  : Get TCPSocket status,Input parameter keepAlive is true; promise
6411     * @tc.size  : MediumTest
6412     * @tc.type  : Function
6413     * @tc.level : level 2
6414     */
6415    it('testNetworkMgrSocketTCPSocketSetExtraOptions3300', 0, async (done: Function) => {
6416      let caseName: string = 'testNetworkMgrSocketTCPSocketSetExtraOptions3300';
6417      console.info(`${caseName} test start`);
6418      try {
6419        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
6420        expect(tcp).assertInstanceOf('Object')
6421        let bindAddress: socket.NetAddress = {
6422          address: '127.0.0.1',
6423          port: 10002
6424        };
6425        await tcp.bind(bindAddress);
6426        let tcpExtraOptions: socket.TCPExtraOptions = {
6427          keepAlive: false,
6428          socketLinger: {
6429            on: false, linger: 10
6430          },
6431        };
6432        tcp.setExtraOptions(tcpExtraOptions).then(() => {
6433          console.info(`${caseName} success `);
6434          expectSuccess();
6435          done();
6436        }).catch((err: BusinessError) => {
6437          console.info(`${caseName} fail err:${JSON.stringify(err)}`);
6438          expectFail();
6439          done();
6440        }).finally(async () => {
6441          await tcp.close();
6442          console.info(`${caseName} test end`);
6443          done();
6444        });
6445      } catch (err) {
6446        console.info(`${caseName}_catch fail ${JSON.stringify(err)}`);
6447        expectFail();
6448        console.info(`${caseName} test end`);
6449        done();
6450      }
6451    });
6452
6453    /* *
6454     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_SetExtraOptions_3400
6455     * @tc.name  : testNetworkMgrSocketTCPSocketSetExtraOptions3400
6456     * @tc.desc  : Get TCPSocket status,Input parameter OOBlnLine is false; promise
6457     * @tc.size  : MediumTest
6458     * @tc.type  : Function
6459     * @tc.level : level 2
6460     */
6461    it('testNetworkMgrSocketTCPSocketSetExtraOptions3400', 0, async (done: Function) => {
6462      let caseName: string = 'testNetworkMgrSocketTCPSocketSetExtraOptions3400';
6463      console.info(`${caseName} test start`);
6464      try {
6465        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
6466        expect(tcp).assertInstanceOf('Object')
6467        let bindAddress: socket.NetAddress = {
6468          address: '127.0.0.1',
6469          port: 10003
6470        };
6471        await tcp.bind(bindAddress);
6472        let tcpExtraOptions: socket.TCPExtraOptions = {
6473          OOBInline: false,
6474          socketLinger: {
6475            on: true, linger: 10
6476          },
6477        };
6478        tcp.setExtraOptions(tcpExtraOptions).then(() => {
6479          console.info(`${caseName} success `);
6480          expectSuccess();
6481          done();
6482        }).catch((err: BusinessError) => {
6483          console.info(`${caseName} fail err:${JSON.stringify(err)}`);
6484          expectFail();
6485          done();
6486        }).finally(async () => {
6487          await tcp.close();
6488          console.info(`${caseName} test end`);
6489          done();
6490        });
6491      } catch (err) {
6492        console.info(`${caseName}_catch fail ${JSON.stringify(err)}`);
6493        expectFail();
6494        console.info(`${caseName} test end`);
6495        done();
6496      }
6497    });
6498
6499    /* *
6500     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_SetExtraOptions_3500
6501     * @tc.name  : testNetworkMgrSocketTCPSocketSetExtraOptions3500
6502     * @tc.desc  : Get TCPSocket status, Input parameter OOBlnLine is true; promise
6503     * @tc.size  : MediumTest
6504     * @tc.type  : Function
6505     * @tc.level : level 2
6506     */
6507    it('testNetworkMgrSocketTCPSocketSetExtraOptions3500', 0, async (done: Function) => {
6508      let caseName: string = 'testNetworkMgrSocketTCPSocketSetExtraOptions3500';
6509      console.info(`${caseName} test start`);
6510      try {
6511        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
6512        expect(tcp).assertInstanceOf('Object')
6513        let bindAddress: socket.NetAddress = {
6514          address: '127.0.0.1',
6515          port: 10003
6516        };
6517        await tcp.bind(bindAddress);
6518        let tcpExtraOptions: socket.TCPExtraOptions = {
6519          OOBInline: true,
6520          socketLinger: {
6521            on: true, linger: 10
6522          },
6523        };
6524        tcp.setExtraOptions(tcpExtraOptions).then(() => {
6525          console.info(`${caseName} success `);
6526          expectSuccess();
6527          done();
6528        }).catch((err: BusinessError) => {
6529          console.info(`${caseName} fail err:${JSON.stringify(err)}`);
6530          expectFail();
6531          done();
6532        }).finally(async () => {
6533          await tcp.close();
6534          console.info(`${caseName} test end`);
6535          done();
6536        });
6537      } catch (err) {
6538        console.info(`${caseName}_catch fail ${JSON.stringify(err)}`);
6539        expectFail();
6540        console.info(`${caseName} test end`);
6541        done();
6542      }
6543    });
6544
6545    /* *
6546     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_SetExtraOptions_3600
6547     * @tc.name  : testNetworkMgrSocketTCPSocketSetExtraOptions3600
6548     * @tc.desc  : Get TCPSocket status,Input parameter TCPNoDelay is false; promise
6549     * @tc.size  : MediumTest
6550     * @tc.type  : Function
6551     * @tc.level : level 2
6552     */
6553    it('testNetworkMgrSocketTCPSocketSetExtraOptions3600', 0, async (done: Function) => {
6554      let caseName: string = 'testNetworkMgrSocketTCPSocketSetExtraOptions3600';
6555      console.info(`${caseName} test start`);
6556      try {
6557        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
6558        expect(tcp).assertInstanceOf('Object')
6559        let bindAddress: socket.NetAddress = {
6560          address: '127.0.0.1',
6561          port: 10004
6562        };
6563        await tcp.bind(bindAddress);
6564        let tcpExtraOptions: socket.TCPExtraOptions = {
6565          TCPNoDelay: false,
6566          socketLinger: {
6567            on: true, linger: 10
6568          },
6569        };
6570        tcp.setExtraOptions(tcpExtraOptions).then(() => {
6571          console.info(`${caseName} success `);
6572          expectSuccess();
6573          done();
6574        }).catch((err: BusinessError) => {
6575          console.info(`${caseName} fail err:${JSON.stringify(err)}`);
6576          expectFail();
6577          done();
6578        }).finally(async () => {
6579          await tcp.close();
6580          console.info(`${caseName} test end`);
6581          done();
6582        });
6583      } catch (err) {
6584        console.info(`${caseName}_catch fail ${JSON.stringify(err)}`);
6585        expectFail();
6586        console.info(`${caseName} test end`);
6587        done();
6588      }
6589    });
6590
6591    /* *
6592     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_SetExtraOptions_3700
6593     * @tc.name  : testNetworkMgrSocketTCPSocketSetExtraOptions3700
6594     * @tc.desc  : Get TCPSocket status,Input parameter TCPNoDelay is true; promise
6595     * @tc.size  : MediumTest
6596     * @tc.type  : Function
6597     * @tc.level : level 2
6598     */
6599    it('testNetworkMgrSocketTCPSocketSetExtraOptions3700', 0, async (done: Function) => {
6600      let caseName: string = 'testNetworkMgrSocketTCPSocketSetExtraOptions3700';
6601      console.info(`${caseName} test start`);
6602      try {
6603        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
6604        expect(tcp).assertInstanceOf('Object')
6605        let bindAddress: socket.NetAddress = {
6606          address: '127.0.0.1',
6607          port: 10004
6608        };
6609        await tcp.bind(bindAddress);
6610        let tcpExtraOptions: socket.TCPExtraOptions = {
6611          TCPNoDelay: false,
6612          socketLinger: {
6613            on: true, linger: 10
6614          },
6615        };
6616        tcp.setExtraOptions(tcpExtraOptions).then(() => {
6617          console.info(`${caseName} success `);
6618          expectSuccess();
6619          done();
6620        }).catch((err: BusinessError) => {
6621          console.info(`${caseName} fail err:${JSON.stringify(err)}`);
6622          expectFail();
6623          done();
6624        }).finally(async () => {
6625          await tcp.close();
6626          console.info(`${caseName} test end`);
6627          done();
6628        });
6629      } catch (err) {
6630        console.info(`${caseName}_catch fail ${JSON.stringify(err)}`);
6631        expectFail();
6632        console.info(`${caseName} test end`);
6633        done();
6634      }
6635    });
6636
6637    /* *
6638     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_SetExtraOptions_3800
6639     * @tc.name  : testNetworkMgrSocketTCPSocketSetExtraOptions3800
6640     * @tc.desc  : Get TCPSocket status,Input parameter receiveBufferSize is -1; promise
6641     * @tc.size  : MediumTest
6642     * @tc.type  : Function
6643     * @tc.level : level 2
6644     */
6645    it('testNetworkMgrSocketTCPSocketSetExtraOptions3800', 0, async (done: Function) => {
6646      let caseName: string = 'testNetworkMgrSocketTCPSocketSetExtraOptions3800';
6647      console.info(`${caseName} test start`);
6648      try {
6649        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
6650        expect(tcp).assertInstanceOf('Object')
6651        let bindAddress: socket.NetAddress = {
6652          address: '127.0.0.1',
6653          port: 10005
6654        };
6655        await tcp.bind(bindAddress);
6656        let tcpExtraOptions: socket.TCPExtraOptions = {
6657          receiveBufferSize: -1,
6658          socketLinger: {
6659            on: true, linger: 10
6660          },
6661        };
6662        tcp.setExtraOptions(tcpExtraOptions).then(() => {
6663          console.info(`${caseName} success `);
6664          expectSuccess();
6665          done();
6666        }).catch((err: BusinessError) => {
6667          console.info(`${caseName} fail err:${JSON.stringify(err)}`);
6668          expectFail();
6669          done();
6670        }).finally(async () => {
6671          await tcp.close();
6672          console.info(`${caseName} test end`);
6673          done();
6674        });
6675      } catch (err) {
6676        console.info(`${caseName}_catch fail ${JSON.stringify(err)}`);
6677        expectFail();
6678        console.info(`${caseName} test end`);
6679        done();
6680      }
6681    });
6682
6683    /* *
6684     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_SetExtraOptions_3900
6685     * @tc.name  : testNetworkMgrSocketTCPSocketSetExtraOptions3900
6686     * @tc.desc  : Get TCPSocket status,Input parameter receiveBufferSize is 0; promise
6687     * @tc.size  : MediumTest
6688     * @tc.type  : Function
6689     * @tc.level : level 2
6690     */
6691    it('testNetworkMgrSocketTCPSocketSetExtraOptions3900', 0, async (done: Function) => {
6692      let caseName: string = 'testNetworkMgrSocketTCPSocketSetExtraOptions3900';
6693      console.info(`${caseName} test start`);
6694      try {
6695        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
6696        expect(tcp).assertInstanceOf('Object')
6697        let bindAddress: socket.NetAddress = {
6698          address: '127.0.0.1',
6699          port: 10006
6700        };
6701        await tcp.bind(bindAddress);
6702        let tcpExtraOptions: socket.TCPExtraOptions = {
6703          receiveBufferSize: 0,
6704          socketLinger: {
6705            on: true, linger: 10
6706          },
6707        };
6708        tcp.setExtraOptions(tcpExtraOptions).then(() => {
6709          console.info(`${caseName} success `);
6710          expectSuccess();
6711          done();
6712        }).catch((err: BusinessError) => {
6713          console.info(`${caseName} fail err:${JSON.stringify(err)}`);
6714          expectFail();
6715          done();
6716        }).finally(async () => {
6717          await tcp.close();
6718          console.info(`${caseName} test end`);
6719          done();
6720        });
6721      } catch (err) {
6722        console.info(`${caseName}_catch fail ${JSON.stringify(err)}`);
6723        expectFail();
6724        console.info(`${caseName} test end`);
6725        done();
6726      }
6727    });
6728
6729    /* *
6730     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_SetExtraOptions_4000
6731     * @tc.name  : testNetworkMgrSocketTCPSocketSetExtraOptions4000
6732     * @tc.desc  : Get TCPSocket status,Input parameter receiveBufferSize is 100; promise
6733     * @tc.size  : MediumTest
6734     * @tc.type  : Function
6735     * @tc.level : level 2
6736     */
6737    it('testNetworkMgrSocketTCPSocketSetExtraOptions4000', 0, async (done: Function) => {
6738      let caseName: string = 'testNetworkMgrSocketTCPSocketSetExtraOptions4000';
6739      console.info(`${caseName} test start`);
6740      try {
6741        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
6742        expect(tcp).assertInstanceOf('Object')
6743        let bindAddress: socket.NetAddress = {
6744          address: '127.0.0.1',
6745          port: 10007
6746        };
6747        await tcp.bind(bindAddress);
6748        let tcpExtraOptions: socket.TCPExtraOptions = {
6749          receiveBufferSize: 100,
6750          socketLinger: {
6751            on: true, linger: 10
6752          },
6753        };
6754        tcp.setExtraOptions(tcpExtraOptions).then(() => {
6755          console.info(`${caseName} success `);
6756          expectSuccess();
6757          done();
6758        }).catch((err: BusinessError) => {
6759          console.info(`${caseName} fail err:${JSON.stringify(err)}`);
6760          expectFail();
6761          done();
6762        }).finally(async () => {
6763          await tcp.close();
6764          console.info(`${caseName} test end`);
6765          done();
6766        });
6767      } catch (err) {
6768        console.info(`${caseName}_catch fail ${JSON.stringify(err)}`);
6769        expectFail();
6770        console.info(`${caseName} test end`);
6771        done();
6772      }
6773    });
6774
6775    /* *
6776     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_SetExtraOptions_4100
6777     * @tc.name  : testNetworkMgrSocketTCPSocketSetExtraOptions4100
6778     * @tc.desc  : Get TCPSocket status,Input parameter sendBufferSize is -1; promise
6779     * @tc.size  : MediumTest
6780     * @tc.type  : Function
6781     * @tc.level : level 2
6782     */
6783    it('testNetworkMgrSocketTCPSocketSetExtraOptions4100', 0, async (done: Function) => {
6784      let caseName: string = 'testNetworkMgrSocketTCPSocketSetExtraOptions4100';
6785      console.info(`${caseName} test start`);
6786      try {
6787        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
6788        expect(tcp).assertInstanceOf('Object')
6789        let bindAddress: socket.NetAddress = {
6790          address: '127.0.0.1',
6791          port: 10008
6792        };
6793        await tcp.bind(bindAddress);
6794        let tcpExtraOptions: socket.TCPExtraOptions = {
6795          sendBufferSize: -1,
6796          socketLinger: {
6797            on: true, linger: 10
6798          },
6799        };
6800        tcp.setExtraOptions(tcpExtraOptions).then(() => {
6801          console.info(`${caseName} success `);
6802          expectSuccess();
6803          done();
6804        }).catch((err: BusinessError) => {
6805          console.info(`${caseName} fail err:${JSON.stringify(err)}`);
6806          expectFail();
6807          done();
6808        }).finally(async () => {
6809          await tcp.close();
6810          console.info(`${caseName} test end`);
6811          done();
6812        });
6813      } catch (err) {
6814        console.info(`${caseName}_catch fail ${JSON.stringify(err)}`);
6815        expectFail();
6816        console.info(`${caseName} test end`);
6817        done();
6818      }
6819    });
6820
6821    /* *
6822     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_SetExtraOptions_4200
6823     * @tc.name  : testNetworkMgrSocketTCPSocketSetExtraOptions4200
6824     * @tc.desc  : Get TCPSocket status,Input parameter sendBufferSize is 0; promise
6825     * @tc.size  : MediumTest
6826     * @tc.type  : Function
6827     * @tc.level : level 2
6828     */
6829    it('testNetworkMgrSocketTCPSocketSetExtraOptions4200', 0, async (done: Function) => {
6830      let caseName: string = 'testNetworkMgrSocketTCPSocketSetExtraOptions4200';
6831      console.info(`${caseName} test start`);
6832      try {
6833        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
6834        expect(tcp).assertInstanceOf('Object')
6835        let bindAddress: socket.NetAddress = {
6836          address: '127.0.0.1',
6837          port: 10008
6838        };
6839        await tcp.bind(bindAddress);
6840        let tcpExtraOptions: socket.TCPExtraOptions = {
6841          sendBufferSize: 0,
6842          socketLinger: {
6843            on: true, linger: 10
6844          },
6845        };
6846        tcp.setExtraOptions(tcpExtraOptions).then(() => {
6847          console.info(`${caseName} success `);
6848          expectSuccess();
6849          done();
6850        }).catch((err: BusinessError) => {
6851          console.info(`${caseName} fail err:${JSON.stringify(err)}`);
6852          expectFail();
6853          done();
6854        }).finally(async () => {
6855          await tcp.close();
6856          console.info(`${caseName} test end`);
6857          done();
6858        });
6859      } catch (err) {
6860        console.info(`${caseName}_catch fail ${JSON.stringify(err)}`);
6861        expectFail();
6862        console.info(`${caseName} test end`);
6863        done();
6864      }
6865    });
6866
6867    /* *
6868     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_SetExtraOptions_4300
6869     * @tc.name  : testNetworkMgrSocketTCPSocketSetExtraOptions4300
6870     * @tc.desc  : Get TCPSocket status,Input parameter sendBufferSize is 100; promise
6871     * @tc.size  : MediumTest
6872     * @tc.type  : Function
6873     * @tc.level : level 2
6874     */
6875    it('testNetworkMgrSocketTCPSocketSetExtraOptions4300', 0, async (done: Function) => {
6876      let caseName: string = 'testNetworkMgrSocketTCPSocketSetExtraOptions4300';
6877      console.info(`${caseName} test start`);
6878      try {
6879        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
6880        expect(tcp).assertInstanceOf('Object')
6881        let bindAddress: socket.NetAddress = {
6882          address: '127.0.0.1',
6883          port: 10008
6884        };
6885        await tcp.bind(bindAddress);
6886        let tcpExtraOptions: socket.TCPExtraOptions = {
6887          sendBufferSize: 100,
6888          socketLinger: {
6889            on: true, linger: 10
6890          },
6891        };
6892        tcp.setExtraOptions(tcpExtraOptions).then(() => {
6893          console.info(`${caseName} success `);
6894          expectSuccess();
6895          done();
6896        }).catch((err: BusinessError) => {
6897          console.info(`${caseName} fail err:${JSON.stringify(err)}`);
6898          expectFail();
6899          done();
6900        }).finally(async () => {
6901          await tcp.close();
6902          console.info(`${caseName} test end`);
6903          done();
6904        });
6905      } catch (err) {
6906        console.info(`${caseName}_catch fail ${JSON.stringify(err)}`);
6907        expectFail();
6908        console.info(`${caseName} test end`);
6909        done();
6910      }
6911    });
6912
6913    /* *
6914     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_SetExtraOptions_4400
6915     * @tc.name  : testNetworkMgrSocketTCPSocketSetExtraOptions4400
6916     * @tc.desc  : Get TCPSocket status,Input parameter reuseAddress is true; promise
6917     * @tc.size  : MediumTest
6918     * @tc.type  : Function
6919     * @tc.level : level 2
6920     */
6921    it('testNetworkMgrSocketTCPSocketSetExtraOptions4400', 0, async (done: Function) => {
6922      let caseName: string = 'testNetworkMgrSocketTCPSocketSetExtraOptions4400';
6923      console.info(`${caseName} test start`);
6924      try {
6925        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
6926        expect(tcp).assertInstanceOf('Object')
6927        let bindAddress: socket.NetAddress = {
6928          address: '127.0.0.1',
6929          port: 10009
6930        };
6931        await tcp.bind(bindAddress);
6932        let tcpExtraOptions: socket.TCPExtraOptions = {
6933          reuseAddress: true,
6934          socketLinger: {
6935            on: true, linger: 10
6936          },
6937        };
6938        tcp.setExtraOptions(tcpExtraOptions).then(() => {
6939          console.info(`${caseName} success `);
6940          expectSuccess();
6941          done();
6942        }).catch((err: BusinessError) => {
6943          console.info(`${caseName} fail err:${JSON.stringify(err)}`);
6944          expectFail();
6945          done();
6946        }).finally(async () => {
6947          await tcp.close();
6948          console.info(`${caseName} test end`);
6949          done();
6950        });
6951      } catch (err) {
6952        console.info(`${caseName}_catch fail ${JSON.stringify(err)}`);
6953        expectFail();
6954        console.info(`${caseName} test end`);
6955        done();
6956      }
6957    });
6958
6959    /* *
6960     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_SetExtraOptions_4500
6961     * @tc.name  : testNetworkMgrSocketTCPSocketSetExtraOptions4500
6962     * @tc.desc  : Get TCPSocket status,Input parameter reuseAddress is false; promise
6963     * @tc.size  : MediumTest
6964     * @tc.type  : Function
6965     * @tc.level : level 2
6966     */
6967    it('testNetworkMgrSocketTCPSocketSetExtraOptions4500', 0, async (done: Function) => {
6968      let caseName: string = 'testNetworkMgrSocketTCPSocketSetExtraOptions4500';
6969      console.info(`${caseName} test start`);
6970      try {
6971        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
6972        expect(tcp).assertInstanceOf('Object')
6973        let bindAddress: socket.NetAddress = {
6974          address: '127.0.0.1',
6975          port: 10010
6976        };
6977        await tcp.bind(bindAddress);
6978        let tcpExtraOptions: socket.TCPExtraOptions = {
6979          reuseAddress: false,
6980          socketLinger: {
6981            on: true, linger: 10
6982          },
6983        };
6984        tcp.setExtraOptions(tcpExtraOptions).then(() => {
6985          console.info(`${caseName} success `);
6986          expectSuccess();
6987          done();
6988        }).catch((err: BusinessError) => {
6989          console.info(`${caseName} fail err:${JSON.stringify(err)}`);
6990          expectFail();
6991          done();
6992        }).finally(async () => {
6993          await tcp.close();
6994          console.info(`${caseName} test end`);
6995          done();
6996        });
6997      } catch (err) {
6998        console.info(`${caseName}_catch fail ${JSON.stringify(err)}`);
6999        expectFail();
7000        console.info(`${caseName} test end`);
7001        done();
7002      }
7003    });
7004
7005    /* *
7006     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_SetExtraOptions_4600
7007     * @tc.name  : testNetworkMgrSocketTCPSocketSetExtraOptions4600
7008     * @tc.desc  : Get TCPSocket status,Input parameter socketTimeout is -1; promise
7009     * @tc.size  : MediumTest
7010     * @tc.type  : Function
7011     * @tc.level : level 2
7012     */
7013    it('testNetworkMgrSocketTCPSocketSetExtraOptions4600', 0, async (done: Function) => {
7014      let caseName: string = 'testNetworkMgrSocketTCPSocketSetExtraOptions4600';
7015      console.info(`${caseName} test start`);
7016      try {
7017        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
7018        expect(tcp).assertInstanceOf('Object')
7019        let bindAddress: socket.NetAddress = {
7020          address: '127.0.0.1',
7021          port: 10011
7022        };
7023        await tcp.bind(bindAddress);
7024        let tcpExtraOptions: socket.TCPExtraOptions = {
7025          socketTimeout: -1,
7026          socketLinger: {
7027            on: true, linger: 10
7028          },
7029        };
7030        tcp.setExtraOptions(tcpExtraOptions).then(() => {
7031          console.info(`${caseName} success `);
7032          expectFail();
7033          done();
7034        }).catch((err: BusinessError) => {
7035          console.info(`${caseName} fail err:${JSON.stringify(err)}`);
7036          expectTrue(err.code===2301033);
7037          done();
7038        }).finally(async () => {
7039          await tcp.close();
7040          console.info(`${caseName} test end`);
7041          done();
7042        });
7043      } catch (err) {
7044        console.info(`${caseName}_catch fail ${JSON.stringify(err)}`);
7045        expectFail();
7046        console.info(`${caseName} test end`);
7047        done();
7048      }
7049    });
7050
7051    /* *
7052     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_SetExtraOptions_4700
7053     * @tc.name  : testNetworkMgrSocketTCPSocketSetExtraOptions4700
7054     * @tc.desc  : Get TCPSocket status,Input parameter socketTimeout is 0; promise
7055     * @tc.size  : MediumTest
7056     * @tc.type  : Function
7057     * @tc.level : level 2
7058     */
7059    it('testNetworkMgrSocketTCPSocketSetExtraOptions4700', 0, async (done: Function) => {
7060      let caseName: string = 'testNetworkMgrSocketTCPSocketSetExtraOptions4700';
7061      console.info(`${caseName} test start`);
7062      try {
7063        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
7064        expect(tcp).assertInstanceOf('Object')
7065        let bindAddress: socket.NetAddress = {
7066          address: '127.0.0.1',
7067          port: 10012
7068        };
7069        await tcp.bind(bindAddress);
7070        let tcpExtraOptions: socket.TCPExtraOptions = {
7071          socketTimeout: 0,
7072          socketLinger: {
7073            on: true, linger: 10
7074          },
7075        };
7076        tcp.setExtraOptions(tcpExtraOptions).then(() => {
7077          console.info(`${caseName} success `);
7078          expectSuccess();
7079          done();
7080        }).catch((err: BusinessError) => {
7081          console.info(`${caseName} fail err:${JSON.stringify(err)}`);
7082          expectFail();
7083          done();
7084        }).finally(async () => {
7085          await tcp.close();
7086          console.info(`${caseName} test end`);
7087          done();
7088        });
7089      } catch (err) {
7090        console.info(`${caseName}_catch fail ${JSON.stringify(err)}`);
7091        expectFail();
7092        console.info(`${caseName} test end`);
7093        done();
7094      }
7095    });
7096
7097    /* *
7098     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_SetExtraOptions_4800
7099     * @tc.name  : testNetworkMgrSocketTCPSocketSetExtraOptions4800
7100     * @tc.desc  : Get TCPSocket status,Input parameter socketTimeout is 100; promise
7101     * @tc.size  : MediumTest
7102     * @tc.type  : Function
7103     * @tc.level : level 2
7104     */
7105    it('testNetworkMgrSocketTCPSocketSetExtraOptions4800', 0, async (done: Function) => {
7106      let caseName: string = 'testNetworkMgrSocketTCPSocketSetExtraOptions4800';
7107      console.info(`${caseName} test start`);
7108      try {
7109        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
7110        expect(tcp).assertInstanceOf('Object')
7111        let bindAddress: socket.NetAddress = {
7112          address: '127.0.0.1',
7113          port: 10013
7114        };
7115        await tcp.bind(bindAddress);
7116        let tcpExtraOptions: socket.TCPExtraOptions = {
7117          socketTimeout: 100,
7118          socketLinger: {
7119            on: true, linger: 10
7120          },
7121        };
7122        tcp.setExtraOptions(tcpExtraOptions).then(() => {
7123          console.info(`${caseName} success `);
7124          expectSuccess();
7125          done();
7126        }).catch((err: BusinessError) => {
7127          console.info(`${caseName} fail err:${JSON.stringify(err)}`);
7128          expectFail();
7129          done();
7130        }).finally(async () => {
7131          await tcp.close();
7132          console.info(`${caseName} test end`);
7133          done();
7134        });
7135      } catch (err) {
7136        console.info(`${caseName}_catch fail ${JSON.stringify(err)}`);
7137        expectFail();
7138        console.info(`${caseName} test end`);
7139        done();
7140      }
7141    });
7142
7143    /* *
7144     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_SetExtraOptions_4900
7145     * @tc.name  : testNetworkMgrSocketTCPSocketSetExtraOptions4900
7146     * @tc.desc  : Get TCPSocket status,Input parameter linger is -1; promise
7147     * @tc.size  : MediumTest
7148     * @tc.type  : Function
7149     * @tc.level : level 2
7150     */
7151    it('testNetworkMgrSocketTCPSocketSetExtraOptions4900', 0, async (done: Function) => {
7152      let caseName: string = 'testNetworkMgrSocketTCPSocketSetExtraOptions4900';
7153      console.info(`${caseName} test start`);
7154      try {
7155        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
7156        expect(tcp).assertInstanceOf('Object')
7157        let bindAddress: socket.NetAddress = {
7158          address: '127.0.0.1',
7159          port: 10014
7160        };
7161        await tcp.bind(bindAddress);
7162        let tcpExtraOptions: socket.TCPExtraOptions = {
7163          socketLinger: {
7164            on: true, linger: -1
7165          },
7166        };
7167        tcp.setExtraOptions(tcpExtraOptions).then(() => {
7168          console.info(`${caseName} success `);
7169          expectSuccess();
7170          done();
7171        }).catch((err: BusinessError) => {
7172          console.info(`${caseName} fail err:${JSON.stringify(err)}`);
7173          expectFail();
7174          done();
7175        }).finally(async () => {
7176          await tcp.close();
7177          console.info(`${caseName} test end`);
7178          done();
7179        });
7180      } catch (err) {
7181        console.info(`${caseName}_catch fail ${JSON.stringify(err)}`);
7182        expectFail();
7183        console.info(`${caseName} test end`);
7184        done();
7185      }
7186    });
7187
7188    /* *
7189     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_SetExtraOptions_5000
7190     * @tc.name  : testNetworkMgrSocketTCPSocketSetExtraOptions5000
7191     * @tc.desc  : Get TCPSocket status,Input parameter linger is 0; promise
7192     * @tc.size  : MediumTest
7193     * @tc.type  : Function
7194     * @tc.level : level 2
7195     */
7196    it('testNetworkMgrSocketTCPSocketSetExtraOptions5000', 0, async (done: Function) => {
7197      let caseName: string = 'testNetworkMgrSocketTCPSocketSetExtraOptions5000';
7198      console.info(`${caseName} test start`);
7199      try {
7200        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
7201        expect(tcp).assertInstanceOf('Object');
7202        let bindAddress: socket.NetAddress = {
7203          address: '127.0.0.1',
7204          port: 10015
7205        };
7206        await tcp.bind(bindAddress);
7207        let tcpExtraOptions: socket.TCPExtraOptions = {
7208          socketLinger: {
7209            on: true, linger: 0
7210          },
7211        };
7212        tcp.setExtraOptions(tcpExtraOptions).then(() => {
7213          console.info(`${caseName} success `);
7214          expectSuccess();
7215          done();
7216        }).catch((err: BusinessError) => {
7217          console.info(`${caseName} fail err:${JSON.stringify(err)}`);
7218          expectFail();
7219          done();
7220        }).finally(async () => {
7221          await tcp.close();
7222          console.info(`${caseName} test end`);
7223          done();
7224        });
7225      } catch (err) {
7226        console.info(`${caseName}_catch fail ${JSON.stringify(err)}`);
7227        expectFail();
7228        console.info(`${caseName} test end`);
7229        done();
7230      }
7231    });
7232
7233    /* *
7234     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_SetExtraOptions_5100
7235     * @tc.name  : testNetworkMgrSocketTCPSocketSetExtraOptions5100
7236     * @tc.desc  : Get TCPSocket status,Input parameter linger is 65535; promise
7237     * @tc.size  : MediumTest
7238     * @tc.type  : Function
7239     * @tc.level : level 2
7240     */
7241    it('testNetworkMgrSocketTCPSocketSetExtraOptions5100', 0, async (done: Function) => {
7242      let caseName: string = 'testNetworkMgrSocketTCPSocketSetExtraOptions5100';
7243      console.info(`${caseName} test start`);
7244      try {
7245        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
7246        expect(tcp).assertInstanceOf('Object');
7247        let bindAddress: socket.NetAddress = {
7248          address: '127.0.0.1',
7249          port: 10017
7250        };
7251        await tcp.bind(bindAddress);
7252        let tcpExtraOptions: socket.TCPExtraOptions = {
7253          socketLinger: {
7254            on: true, linger: 65535
7255          },
7256        };
7257        tcp.setExtraOptions(tcpExtraOptions).then(() => {
7258          console.info(`${caseName} success `);
7259          expectSuccess();
7260          done();
7261        }).catch((err: BusinessError) => {
7262          console.info(`${caseName} fail err:${JSON.stringify(err)}`);
7263          expectFail();
7264          done();
7265        }).finally(async () => {
7266          await tcp.close();
7267          console.info(`${caseName} test end`);
7268          done();
7269        });
7270      } catch (err) {
7271        console.info(`${caseName}_catch fail ${JSON.stringify(err)}`);
7272        expectFail();
7273        console.info(`${caseName} test end`);
7274        done();
7275      }
7276    });
7277
7278    /* *
7279     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_SetExtraOptions_5200
7280     * @tc.name  : testNetworkMgrSocketTCPSocketSetExtraOptions5200
7281     * @tc.desc  : Get TCPSocket status,Input parameter linger is 65536; promise
7282     * @tc.size  : MediumTest
7283     * @tc.type  : Function
7284     * @tc.level : level 2
7285     */
7286    it('testNetworkMgrSocketTCPSocketSetExtraOptions5200', 0, async (done: Function) => {
7287      let caseName: string = 'testNetworkMgrSocketTCPSocketSetExtraOptions5200';
7288      console.info(`${caseName} test start`);
7289      try {
7290        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
7291        expect(tcp).assertInstanceOf('Object')
7292        let bindAddress: socket.NetAddress = {
7293          address: '127.0.0.1',
7294          port: 10018
7295        };
7296        await tcp.bind(bindAddress);
7297        let tcpExtraOptions: socket.TCPExtraOptions = {
7298          socketLinger: {
7299            on: true, linger: 65536
7300          },
7301        };
7302        tcp.setExtraOptions(tcpExtraOptions).then(() => {
7303          console.info(`${caseName} success `);
7304          expectSuccess();
7305          done();
7306        }).catch((err: BusinessError) => {
7307          console.info(`${caseName} fail err:${JSON.stringify(err)}`);
7308          expectFail();
7309          done();
7310        }).finally(async () => {
7311          await tcp.close();
7312          console.info(`${caseName} test end`);
7313          done();
7314        });
7315      } catch (err) {
7316        console.info(`${caseName}_catch fail ${JSON.stringify(err)}`);
7317        expectFail();
7318        console.info(`${caseName} test end`);
7319        done();
7320      }
7321    });
7322
7323    /* *
7324     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_OnMessage_0100
7325     * @tc.name  : testNetworkMgrSocketTCPSocketOnMessage0100
7326     * @tc.desc  : Subscription to receive message events for TCPSocket connections,after bind and connect
7327     * @tc.size  : MediumTest
7328     * @tc.type  : Function
7329     * @tc.level : level 2
7330     */
7331    it('testNetworkMgrSocketTCPSocketOnMessage0100', 0, async (done: Function) => {
7332      let caseName: string = 'testNetworkMgrSocketTCPSocketOnMessage0100';
7333       try {
7334        console.info(`${caseName} test start`);
7335        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
7336        expect(tcp).assertInstanceOf('Object');
7337        let tcpServer: socket.TCPSocketServer = socket.constructTCPSocketServerInstance();
7338        expect(tcpServer).assertInstanceOf('Object');
7339        let listenAddress: socket.NetAddress = {
7340          address: '127.0.0.1',
7341          port: 4092
7342        };
7343        await tcpServer.listen(listenAddress);
7344        let tcpConnectOptions: socket.TCPConnectOptions = {
7345          address: listenAddress,
7346        };
7347        let clientSendOptions: socket.TCPSendOptions = {
7348          data: 'Hello, server!',
7349          encoding: 'UTF-8'
7350        };
7351        tcpServer.on('connect', async (client: socket.TCPSocketConnection) => {
7352          await client.send(clientSendOptions);
7353        });
7354        await tcp.connect(tcpConnectOptions);
7355        class SocketInfo {
7356          message: ArrayBuffer = new ArrayBuffer(1);
7357          remoteInfo: socket.SocketRemoteInfo = {} as socket.SocketRemoteInfo;
7358        };
7359        const callback: Callback<socket.SocketMessageInfo> = async (value: SocketInfo) => {
7360          console.info(`${caseName} value:${ArrayBufferToString(value.message)}`);
7361          expectTrue(ArrayBufferToString(value.message) === 'Hello, server!');
7362          tcpServer.off('connect');
7363          await tcp.close();
7364          console.info(`${caseName} test end`);
7365          done();
7366        };
7367        tcp.on('message', callback);
7368      } catch (err) {
7369        console.info(`${caseName}_catch fail err:${JSON.stringify(err)}`);
7370        expectFail();
7371        console.info(`${caseName} test end`);
7372        done();
7373      }
7374    });
7375
7376    /* *
7377     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_OnMessage_0200
7378     * @tc.name  : testNetworkMgrSocketTCPSocketOnMessage0200
7379     * @tc.desc  : Subscription to receive message events for TCPSocket connections,after listen and connect
7380     * @tc.size  : MediumTest
7381     * @tc.type  : Function
7382     * @tc.level : level 2
7383     */
7384    it('testNetworkMgrSocketTCPSocketOnMessage0200', 0, async (done: Function) => {
7385      let caseName: string = 'testNetworkMgrSocketTCPSocketOnMessage0200';
7386      try {
7387        console.info(`${caseName} test start`);
7388        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
7389        expect(tcp).assertInstanceOf('Object');
7390        let tcpServer: socket.TCPSocketServer = socket.constructTCPSocketServerInstance();
7391        expect(tcpServer).assertInstanceOf('Object');
7392        let listenAddress: socket.NetAddress = {
7393          address: '127.0.0.1',
7394          port: 4093
7395        };
7396        await tcpServer.listen(listenAddress);
7397        let tcpConnectOptions: socket.TCPConnectOptions = {
7398          address: listenAddress,
7399        };
7400        let clientSendOptions: socket.TCPSendOptions = {
7401          data: 'Hello, server!',
7402          encoding: 'UTF-8'
7403        };
7404        tcpServer.on('connect', async (client: socket.TCPSocketConnection) => {
7405          await client.send(clientSendOptions);
7406        });
7407        await tcp.connect(tcpConnectOptions);
7408        class SocketInfo {
7409          message: ArrayBuffer = new ArrayBuffer(1);
7410          remoteInfo: socket.SocketRemoteInfo = {} as socket.SocketRemoteInfo;
7411        };
7412        const callback: Callback<socket.SocketMessageInfo> = async (value: SocketInfo) => {
7413          console.info(`${caseName} value:${ArrayBufferToString(value.message)}`);
7414          expectTrue(ArrayBufferToString(value.message) === 'Hello, server!');
7415          tcpServer.off('connect');
7416          await tcp.close();
7417          console.info(`${caseName} test end`);
7418          done();
7419        };
7420        tcp.on('message', callback);
7421      } catch (err) {
7422        console.info(`${caseName}_catch fail err:${JSON.stringify(err)}`);
7423        expectFail();
7424        console.info(`${caseName} test end`);
7425        done();
7426      }
7427    });
7428
7429    /* *
7430     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_OffMessage_0100
7431     * @tc.name  : testNetworkMgrSocketTCPSocketOffMessage0100
7432     * @tc.desc  : Unsubscribe from receiving message events for TCPSocket connections,After a subscription
7433     * @tc.size  : MediumTest
7434     * @tc.type  : Function
7435     * @tc.level : level 2
7436     */
7437    it('testNetworkMgrSocketTCPSocketOffMessage0100', 0, async (done: Function) => {
7438      let caseName: string = 'testNetworkMgrSocketTCPSocketOffMessage0100';
7439      try {
7440        console.info(`${caseName} test start`);
7441        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
7442        expect(tcp).assertInstanceOf('Object');
7443        let bindAddress: socket.NetAddress = {
7444          address: '127.0.0.1',
7445          port: 4094
7446        };
7447        await tcp.bind(bindAddress);
7448        let tcpConnectOptions: socket.TCPConnectOptions = {
7449          address: bindAddress,
7450        };
7451        await tcp.connect(tcpConnectOptions);
7452        let tcpSendOptions: socket.TCPSendOptions = {
7453          data: 'Hello, client!',
7454          encoding: 'UTF-8'
7455        };
7456        const callback: Callback<socket.SocketMessageInfo> = () => {
7457          expectFail();
7458          console.info(`${caseName} test end`);
7459          done();
7460        };
7461        tcp.on('message', callback);
7462        tcp.off('message', callback);
7463        await tcp.send(tcpSendOptions);
7464        await tcp.close();
7465        expectSuccess();
7466        done();
7467      } catch (err) {
7468        console.info(`${caseName}_catch fail err:${JSON.stringify(err)}`);
7469        expectFail();
7470        console.info(`${caseName} test end`);
7471        done();
7472      }
7473    });
7474
7475    /* *
7476     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_OffMessage_0200
7477     * @tc.name  : testNetworkMgrSocketTCPSocketOffMessage0200
7478     * @tc.desc  : Unsubscribe from receiving message events for TCPSocket connections,After Subscribing multiple times
7479     * @tc.size  : MediumTest
7480     * @tc.type  : Function
7481     * @tc.level : level 2
7482     */
7483    it('testNetworkMgrSocketTCPSocketOffMessage0200', 0, async (done: Function) => {
7484      let caseName: string = 'testNetworkMgrSocketTCPSocketOffMessage0200';
7485      try {
7486        console.info(`${caseName} test start`);
7487        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
7488        expect(tcp).assertInstanceOf('Object');
7489        let bindAddress: socket.NetAddress = {
7490          address: '127.0.0.1',
7491          port: 4095
7492        };
7493        await tcp.bind(bindAddress);
7494        let tcpConnectOptions: socket.TCPConnectOptions = {
7495          address: bindAddress,
7496        };
7497        await tcp.connect(tcpConnectOptions);
7498        let tcpSendOptions: socket.TCPSendOptions = {
7499          data: 'Hello, client!',
7500          encoding: 'UTF-8'
7501        };
7502        const callback1: Callback<socket.SocketMessageInfo> = () => {
7503          expectFail();
7504          console.info(`${caseName} callback1 test end`);
7505          done();
7506        };
7507        const callback2: Callback<socket.SocketMessageInfo> = () => {
7508          expectFail();
7509          console.info(`${caseName} callback2 test end`);
7510          done();
7511        };
7512        tcp.on('message', callback1);
7513        tcp.on('message', callback2);
7514        tcp.off('message');
7515        await tcp.send(tcpSendOptions);
7516        expectSuccess();
7517        await tcp.close();
7518        done();
7519      } catch (err) {
7520        console.info(`${caseName}_catch fail err:${JSON.stringify(err)}`);
7521        expectFail();
7522        console.info(`${caseName} test end`);
7523        done();
7524      }
7525    });
7526
7527    /* *
7528     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_OnConnect_0100
7529     * @tc.name  : testNetworkMgrSocketTCPSocketOnConnect0100
7530     * @tc.desc  : Subscription to connection events for TCPSocket after bind
7531     * @tc.size  : MediumTest
7532     * @tc.type  : Function
7533     * @tc.level : level 2
7534     */
7535    it('testNetworkMgrSocketTCPSocketOnConnect0100', 0, async (done: Function) => {
7536      let caseName: string = 'testNetworkMgrSocketTCPSocketOnConnect0100';
7537      try {
7538        console.info(`${caseName} test start`);
7539        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
7540        expect(tcp).assertInstanceOf('Object');
7541        let bindAddress: socket.NetAddress = {
7542          address: '127.0.0.1',
7543          port: 4096
7544        };
7545        await tcp.bind(bindAddress);
7546        let tcpConnectOptions: socket.TCPConnectOptions = {
7547          address: bindAddress,
7548        };
7549        const callback: Callback<void> = async () => {
7550          expectSuccess();
7551          console.info(`${caseName} test end`);
7552          await tcp.close();
7553          done();
7554        };
7555        tcp.on('connect', callback);
7556        await tcp.connect(tcpConnectOptions);
7557      } catch (err) {
7558        console.info(`${caseName}_catch fail err:${JSON.stringify(err)}`);
7559        expectFail();
7560        console.info(`${caseName} test end`);
7561        done();
7562      }
7563    });
7564
7565    /* *
7566     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_OnConnect_0200
7567     * @tc.name  : testNetworkMgrSocketTCPSocketOnConnect0200
7568     * @tc.desc  : Subscription to connection events for TCPSocket,after listen
7569     * @tc.size  : MediumTest
7570     * @tc.type  : Function
7571     * @tc.level : level 2
7572     */
7573    it('testNetworkMgrSocketTCPSocketOnConnect0200', 0, async (done: Function) => {
7574      let caseName: string = 'testNetworkMgrSocketTCPSocketOnConnect0200';
7575      try {
7576        console.info(`${caseName} test start`);
7577        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
7578        expect(tcp).assertInstanceOf('Object');
7579        let tcpServer: socket.TCPSocketServer = socket.constructTCPSocketServerInstance();
7580        expect(tcpServer).assertInstanceOf('Object');
7581        let listenAddress: socket.NetAddress = {
7582          address: '127.0.0.1',
7583          port: 4097
7584        };
7585        await tcpServer.listen(listenAddress);
7586        let tcpConnectOptions: socket.TCPConnectOptions = {
7587          address: listenAddress,
7588        };
7589        const callback: Callback<void> = async () => {
7590          console.info(`${caseName} test end`);
7591          await tcp.close();
7592          expectSuccess();
7593          done();
7594        };
7595        tcp.on('connect', callback);
7596        await tcp.connect(tcpConnectOptions);
7597        console.info(`${caseName} test end`);
7598        done();
7599      } catch (err) {
7600        console.info(`${caseName}_catch fail err:${JSON.stringify(err)}`);
7601        expectFail();
7602        console.info(`${caseName} test end`);
7603        done();
7604      }
7605    });
7606
7607    /* *
7608     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_OffConnect_0100
7609     * @tc.name  : testNetworkMgrSocketTCPSocketOffConnect0100
7610     * @tc.desc  : Unsubscribe from TCP Socket connection events,After a subscription
7611     * @tc.size  : MediumTest
7612     * @tc.type  : Function
7613     * @tc.level : level 2
7614     */
7615    it('testNetworkMgrSocketTCPSocketOffConnect0100', 0, async (done: Function) => {
7616      let caseName: string = 'testNetworkMgrSocketTCPSocketOffConnect0100';
7617      try {
7618        console.info(`${caseName} test start`);
7619        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
7620        expect(tcp).assertInstanceOf('Object');
7621        let bindAddress: socket.NetAddress = {
7622          address: '127.0.0.1',
7623          port: 4098
7624        };
7625        await tcp.bind(bindAddress);
7626        let tcpConnectOptions: socket.TCPConnectOptions = {
7627          address: bindAddress,
7628        };
7629        const callback: Callback<void> = async () => {
7630          expectFail();
7631          console.info(`${caseName} test end`);
7632          done();
7633        };
7634        tcp.on('connect', callback);
7635        tcp.off('connect', callback);
7636        await tcp.connect(tcpConnectOptions);
7637        expectSuccess();
7638        console.info(`${caseName} test end`);
7639        done();
7640      } catch (err) {
7641        console.info(`${caseName}_catch fail err:${JSON.stringify(err)}`);
7642        expectFail();
7643        console.info(`${caseName} test end`);
7644        done();
7645      }
7646    });
7647
7648    /* *
7649     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_OffConnect_0100
7650     * @tc.name  : testNetworkMgrSocketTCPSocketOffConnect0100
7651     * @tc.desc  :  Unsubscribe from TCP Socket connection events,After Subscribing multiple times
7652     * @tc.size  : MediumTest
7653     * @tc.type  : Function
7654     * @tc.level : level 2
7655     */
7656    it('testNetworkMgrSocketTCPSocketOffConnect0200', 0, async (done: Function) => {
7657      let caseName: string = 'testNetworkMgrSocketTCPSocketOffConnect0200';
7658      try {
7659        console.info(`${caseName} test start`);
7660        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
7661        expect(tcp).assertInstanceOf('Object');
7662        let bindAddress: socket.NetAddress = {
7663          address: '127.0.0.1',
7664          port: 4099
7665        };
7666        await tcp.bind(bindAddress);
7667        let tcpConnectOptions: socket.TCPConnectOptions = {
7668          address: bindAddress,
7669        };
7670        const callback1: Callback<void> = async () => {
7671          expectFail();
7672          console.info(`${caseName} test end`);
7673          done();
7674        };
7675        const callback2: Callback<void> = async () => {
7676          expectFail();
7677          console.info(`${caseName} test end`);
7678          done();
7679        };
7680        tcp.on('connect', callback1);
7681        tcp.on('connect', callback2);
7682        tcp.off('connect');
7683        await tcp.connect(tcpConnectOptions);
7684        expectSuccess();
7685        console.info(`${caseName} test end`);
7686        done();
7687      } catch (err) {
7688        console.info(`${caseName}_catch fail err:${JSON.stringify(err)}`);
7689        expectFail();
7690        console.info(`${caseName} test end`);
7691        done();
7692      }
7693    });
7694
7695    /* *
7696     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_OnClose_0100
7697     * @tc.name  : testNetworkMgrSocketTCPSocketOnClose0100
7698     * @tc.desc  : Subscribe to the closure event of TCPSocket, after bind
7699     * @tc.size  : MediumTest
7700     * @tc.type  : Function
7701     * @tc.level : level 2
7702     */
7703    it('testNetworkMgrSocketTCPSocketOnClose0100', 0, async (done: Function) => {
7704      let caseName: string = 'testNetworkMgrSocketTCPSocketOnClose0100';
7705      try {
7706        console.info(`${caseName} test start`);
7707        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
7708        expect(tcp).assertInstanceOf('Object');
7709        let bindAddress: socket.NetAddress = {
7710          address: '127.0.0.1',
7711          port: 4100
7712        };
7713        await tcp.bind(bindAddress);
7714        const callback: Callback<void> = async () => {
7715          expectSuccess();
7716          console.info(`${caseName} test end`);
7717          done();
7718        };
7719        tcp.on('close', callback);
7720        await tcp.close();
7721        console.info(`${caseName} test end`);
7722        done();
7723      } catch (err) {
7724        console.info(`${caseName}_catch fail err:${JSON.stringify(err)}`);
7725        expectFail();
7726        console.info(`${caseName} test end`);
7727        done();
7728      }
7729    });
7730
7731    /* *
7732     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_OnClose_0200
7733     * @tc.name  : testNetworkMgrSocketTCPSocketOnClose0200
7734     * @tc.desc  : Subscribe to the closure event of TCPSocket,after listen
7735     * @tc.size  : MediumTest
7736     * @tc.type  : Function
7737     * @tc.level : level 2
7738     */
7739    it('testNetworkMgrSocketTCPSocketOnClose0200', 0, async (done: Function) => {
7740      let caseName: string = 'testNetworkMgrSocketTCPSocketOnClose0200';
7741      try {
7742        console.info(`${caseName} test start`);
7743        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
7744        expect(tcp).assertInstanceOf('Object');
7745        let tcpServer: socket.TCPSocketServer = socket.constructTCPSocketServerInstance();
7746        expect(tcpServer).assertInstanceOf('Object');
7747        let listenAddress: socket.NetAddress = {
7748          address: '127.0.0.1',
7749          port: 4101
7750        };
7751        await tcpServer.listen(listenAddress);
7752        let tcpConnectOptions: socket.TCPConnectOptions = {
7753          address: listenAddress,
7754          timeout: 6000
7755        };
7756        await tcp.connect(tcpConnectOptions);
7757        const callback: Callback<void> =  () => {
7758          expectSuccess();
7759          console.info(`${caseName} test end`);
7760          done();
7761        };
7762        tcp.on('close', callback);
7763        await tcp.close();
7764        console.info(`${caseName} test end`);
7765        done();
7766      } catch (err) {
7767        console.info(`${caseName}_catch fail err:${JSON.stringify(err)}`);
7768        expectFail();
7769        console.info(`${caseName} test end`);
7770        done();
7771      }
7772    });
7773
7774    /* *
7775     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_OffClose_0100
7776     * @tc.name  : testNetworkMgrSocketTCPSocketOffClose0100
7777     * @tc.desc  : Unsubscribe from the closing event of TCPSocket,After a subscription
7778     * @tc.size  : MediumTest
7779     * @tc.type  : Function
7780     * @tc.level : level 2
7781     */
7782    it('testNetworkMgrSocketTCPSocketOffClose0100', 0, async (done: Function) => {
7783      let caseName: string = 'testNetworkMgrSocketTCPSocketOffClose0100';
7784      try {
7785        console.info(`${caseName} test start`);
7786        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
7787        expect(tcp).assertInstanceOf('Object');
7788        let bindAddress: socket.NetAddress = {
7789          address: '127.0.0.1',
7790          port: 4102
7791        };
7792        await tcp.bind(bindAddress);
7793        const callback: Callback<void> = async () => {
7794          expectFail();
7795          console.info(`${caseName} test end`);
7796          done();
7797        };
7798        tcp.on('close', callback);
7799        tcp.off('close', callback);
7800        await tcp.close();
7801        expectSuccess();
7802        console.info(`${caseName} test end`);
7803        done();
7804      } catch (err) {
7805        console.info(`${caseName}_catch fail err:${JSON.stringify(err)}`);
7806        expectFail();
7807        console.info(`${caseName} test end`);
7808        done();
7809      }
7810    });
7811
7812    /* *
7813     * @tc.number: SUB_NetworkMgr_Socket_TCPSocket_OffClose_0200
7814     * @tc.name  : testNetworkMgrSocketTCPSocketOffClose0200
7815     * @tc.desc  : Unsubscribe from the closing event of TCPSocket,After Subscribing multiple times
7816     * @tc.size  : MediumTest
7817     * @tc.type  : Function
7818     * @tc.level : level 2
7819     */
7820    it('testNetworkMgrSocketTCPSocketOffClose0200', 0, async (done: Function) => {
7821      let caseName: string = 'testNetworkMgrSocketTCPSocketOffClose0200';
7822      try {
7823        console.info(`${caseName} test start`);
7824        let tcp: socket.TCPSocket = socket.constructTCPSocketInstance();
7825        expect(tcp).assertInstanceOf('Object');
7826        let bindAddress: socket.NetAddress = {
7827          address: '127.0.0.1',
7828          port: 4103
7829        };
7830        await tcp.bind(bindAddress);
7831        const callback1: Callback<void> = async () => {
7832          expectFail();
7833          console.info(`${caseName} test end`);
7834          done();
7835        };
7836        const callback2: Callback<void> = async () => {
7837          expectFail();
7838          console.info(`${caseName} test end`);
7839          done();
7840        };
7841        tcp.on('close', callback1);
7842        tcp.on('close', callback2);
7843        tcp.off('close');
7844        await tcp.close();
7845        expectSuccess();
7846        console.info(`${caseName} test end`);
7847        done();
7848      } catch (err) {
7849        console.info(`${caseName}_catch fail err:${JSON.stringify(err)}`);
7850        expectFail();
7851        console.info(`${caseName} test end`);
7852        done();
7853      }
7854    });
7855
7856
7857  })
7858}
7859