• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 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  */
15 
16 #include <stdio.h>
17 #include <sys/socket.h>
18 #include <netinet/in.h>
19 #include <arpa/inet.h>
20 #include <string.h>
21 #include "test.h"
22 
23 /**
24  * @tc.name      : shutdown_0100
25  * @tc.desc      : The test stops the socket transmission through the shutdown function
26  * @tc.level     : Level 0
27  */
shutdown_0100(void)28 void shutdown_0100(void)
29 {
30     int sd = socket(AF_INET, SOCK_STREAM, 0);
31     struct sockaddr_in server_addr;
32     bzero(&server_addr, sizeof(server_addr));
33     server_addr.sin_addr.s_addr = INADDR_ANY;
34     server_addr.sin_addr.s_addr = INADDR_ANY;
35     server_addr.sin_port = htons(9898);
36     server_addr.sin_family = AF_INET;
37     bind(sd, (struct sockaddr *)(&server_addr), sizeof(server_addr));
38     listen(sd, 5);
39     int result = shutdown(sd, 0);
40     if (result != 0) {
41         t_error("%s shutdown get result is %d are not 0", result);
42     }
43     close(sd);
44 }
45 
main(int argc,char * argv[])46 int main(int argc, char *argv[])
47 {
48     shutdown_0100();
49     return t_status;
50 }