BSD Socket, Winsock and other sockets



# Chapter 7. Sockets

https://docs.freebsd.org/en/books/developers-handbook/sockets/


# Winsock でのはじめに

https://learn.microsoft.com/ja-jp/windows/win32/winsock/getting-started-with-winsock

# AUTOSAR socket

https://www.autosar.org/fileadmin/user_upload/standards/classic/21-11/AUTOSAR_SWS_SocketAdaptor.pdf

# Error

Socket operation on non socket error in C

https://stackoverflow.com/questions/25590965/socket-operation-on-non-socket-error-in-c

```c:appl.c
#define BUFLEN 512
#define MYPORT 3456
void errorp(char* msg)
{
        perror(msg);
        exit(1);
}

int main()
{
        struct sockaddr_in server, client;
        int sock;
        int slen = sizeof(server);
        int clen = sizeof(client);
        char *recvbuf, senbuf[BUFLEN] = {'h','e','l','l','o'};

        if((sock = socket(AF_INET, SOCK_DGRAM, 0) == -1))
                errorp("Socket creation failed");


        printf("To the client: %s, %s", senbuf, " World");
        bzero(&server, sizeof(server));

        server.sin_family = AF_INET;
        server.sin_port = MYPORT;
        server.sin_addr.s_addr = inet_addr("127.0.0.1");
        if(bind(sock, (struct sockaddr*)&server, slen)==-1)
                errorp("Socket Bind Failed");
        if(recvfrom(sock, recvbuf, sizeof(recvbuf), 0, (struct sockaddr*) &client, &clen) == -1)
                errorp("recv from error");
        printf("From the client: %s", recvbuf);

        if(sendto(sock, senbuf, sizeof(senbuf), 0, (struct sockaddr*) &client, sizeof(client)) == -1)
                errorp("Error in sending");

        printf("To the client: %s", senbuf);
        close(sock);
        return 0;
}
```

# cg.sh
```sh:cg.sh
#!/bin/sh
if [  -e $1l ]; then
rm $1l
fi
if [  -e $1g ]; then
rm $1g
fi
echo "$ clang $1.c  -o $1l -I. -Wall" 
clang $1.c  -o $1l -I. -Wall
if [  -e $1l ]; then
./$1l 
fi
if [  -e $1l ]; then
rm $1l
fi
echo "\r"
echo "$ gcc $1.c -o $1g -I. -Wall
gcc $1.c  -o $1g -I. -Wall
if [ -e $1g ]; then
./$1g
fi
if [ -e $1g ]; then
rm $1g
fi
```


## Compile and Go 

```ubuntu:bash
t# ./cg.sh appl
$ clang appl.c  -o appll -I. -Wall
appl.c:5:9: warning: implicit declaration of function 'perror' is invalid in C99 [-Wimplicit-function-declaration]
        perror(msg);
        ^
appl.c:6:9: warning: implicitly declaring library function 'exit' with type 'void (int) __attribute__((noreturn))' [-Wimplicit-function-declaration]
        exit(1);
        ^
appl.c:6:9: note: include the header <stdlib.h> or explicitly provide a declaration for 'exit'
appl.c:11:28: error: variable has incomplete type 'struct sockaddr_in'
        struct sockaddr_in server, client;
                           ^
appl.c:11:16: note: forward declaration of 'struct sockaddr_in'
        struct sockaddr_in server, client;
               ^
appl.c:11:36: error: variable has incomplete type 'struct sockaddr_in'
        struct sockaddr_in server, client;
                                   ^
appl.c:11:16: note: forward declaration of 'struct sockaddr_in'
        struct sockaddr_in server, client;
               ^
appl.c:17:20: warning: implicit declaration of function 'socket' is invalid in C99 [-Wimplicit-function-declaration]
        if((sock = socket(AF_INET, SOCK_DGRAM, 0) == -1))
                   ^
appl.c:17:27: error: use of undeclared identifier 'AF_INET'
        if((sock = socket(AF_INET, SOCK_DGRAM, 0) == -1))
                          ^
appl.c:17:36: error: use of undeclared identifier 'SOCK_DGRAM'
        if((sock = socket(AF_INET, SOCK_DGRAM, 0) == -1))
                                   ^
appl.c:21:9: warning: implicitly declaring library function 'printf' with type 'int (const char *, ...)' [-Wimplicit-function-declaration]
        printf("To the client: %s, %s", senbuf, " World");
        ^
appl.c:21:9: note: include the header <stdio.h> or explicitly provide a declaration for 'printf'
appl.c:22:9: warning: implicitly declaring library function 'bzero' with type 'void (void *, unsigned long)' [-Wimplicit-function-declaration]
        bzero(&server, sizeof(server));
        ^
appl.c:22:9: note: include the header <strings.h> or explicitly provide a declaration for 'bzero'
appl.c:24:29: error: use of undeclared identifier 'AF_INET'
        server.sin_family = AF_INET;
                            ^
appl.c:26:34: warning: implicit declaration of function 'inet_addr' is invalid in C99 [-Wimplicit-function-declaration]
        server.sin_addr.s_addr = inet_addr("127.0.0.1");
                                 ^
appl.c:27:12: warning: implicit declaration of function 'bind' is invalid in C99 [-Wimplicit-function-declaration]
        if(bind(sock, (struct sockaddr*)&server, slen)==-1)
           ^
appl.c:29:12: warning: implicit declaration of function 'recvfrom' is invalid in C99 [-Wimplicit-function-declaration]
        if(recvfrom(sock, recvbuf, sizeof(recvbuf), 0, (struct sockaddr*) &client, &clen) == -1)
           ^
appl.c:33:12: warning: implicit declaration of function 'sendto' is invalid in C99 [-Wimplicit-function-declaration]
        if(sendto(sock, senbuf, sizeof(senbuf), 0, (struct sockaddr*) &client, sizeof(client)) == -1)
           ^
appl.c:37:9: warning: implicit declaration of function 'close' is invalid in C99 [-Wimplicit-function-declaration]
        close(sock);
        ^
10 warnings and 5 errors generated.

./cg.sh: 25: Syntax error: Unterminated quoted string
```
## cg.sh 修正

```sh:cg.sh
#!/bin/sh
if [  -e $1l ]; then
rm $1l
fi
if [  -e $1g ]; then
rm $1g
fi
echo "$ clang $1.c  -o $1l -I. -Wall" 
clang $1.c  -o $1l -I. -Wall
if [  -e $1l ]; then
./$1l 
fi
if [  -e $1l ]; then
rm $1l
fi
echo "\r"
echo "$ gcc $1.c -o $1g -I. -Wall"
gcc $1.c  -o $1g -I. -Wall
if [ -e $1g ]; then
./$1g
fi
if [ -e $1g ]; then
rm $1g
fi
```

## build and go

```ubuntu:bash
 ./cg.sh appl
$ clang appl.c  -o appll -I. -Wall
appl.c:5:9: warning: implicit declaration of function 'perror' is invalid in C99 [-Wimplicit-function-declaration]
        perror(msg);
        ^
appl.c:6:9: warning: implicitly declaring library function 'exit' with type 'void (int) __attribute__((noreturn))' [-Wimplicit-function-declaration]
        exit(1);
        ^
appl.c:6:9: note: include the header <stdlib.h> or explicitly provide a declaration for 'exit'
appl.c:11:28: error: variable has incomplete type 'struct sockaddr_in'
        struct sockaddr_in server, client;
                           ^
appl.c:11:16: note: forward declaration of 'struct sockaddr_in'
        struct sockaddr_in server, client;
               ^
appl.c:11:36: error: variable has incomplete type 'struct sockaddr_in'
        struct sockaddr_in server, client;
                                   ^
appl.c:11:16: note: forward declaration of 'struct sockaddr_in'
        struct sockaddr_in server, client;
               ^
appl.c:17:20: warning: implicit declaration of function 'socket' is invalid in C99 [-Wimplicit-function-declaration]
        if((sock = socket(AF_INET, SOCK_DGRAM, 0) == -1))
                   ^
appl.c:17:27: error: use of undeclared identifier 'AF_INET'
        if((sock = socket(AF_INET, SOCK_DGRAM, 0) == -1))
                          ^
appl.c:17:36: error: use of undeclared identifier 'SOCK_DGRAM'
        if((sock = socket(AF_INET, SOCK_DGRAM, 0) == -1))
                                   ^
appl.c:21:9: warning: implicitly declaring library function 'printf' with type 'int (const char *, ...)' [-Wimplicit-function-declaration]
        printf("To the client: %s, %s", senbuf, " World");
        ^
appl.c:21:9: note: include the header <stdio.h> or explicitly provide a declaration for 'printf'
appl.c:22:9: warning: implicitly declaring library function 'bzero' with type 'void (void *, unsigned long)' [-Wimplicit-function-declaration]
        bzero(&server, sizeof(server));
        ^
appl.c:22:9: note: include the header <strings.h> or explicitly provide a declaration for 'bzero'
appl.c:24:29: error: use of undeclared identifier 'AF_INET'
        server.sin_family = AF_INET;
                            ^
appl.c:26:34: warning: implicit declaration of function 'inet_addr' is invalid in C99 [-Wimplicit-function-declaration]
        server.sin_addr.s_addr = inet_addr("127.0.0.1");
                                 ^
appl.c:27:12: warning: implicit declaration of function 'bind' is invalid in C99 [-Wimplicit-function-declaration]
        if(bind(sock, (struct sockaddr*)&server, slen)==-1)
           ^
appl.c:29:12: warning: implicit declaration of function 'recvfrom' is invalid in C99 [-Wimplicit-function-declaration]
        if(recvfrom(sock, recvbuf, sizeof(recvbuf), 0, (struct sockaddr*) &client, &clen) == -1)
           ^
appl.c:33:12: warning: implicit declaration of function 'sendto' is invalid in C99 [-Wimplicit-function-declaration]
        if(sendto(sock, senbuf, sizeof(senbuf), 0, (struct sockaddr*) &client, sizeof(client)) == -1)
           ^
appl.c:37:9: warning: implicit declaration of function 'close' is invalid in C99 [-Wimplicit-function-declaration]
        close(sock);
        ^
10 warnings and 5 errors generated.

$ gcc appl.c -o applg -I. -Wall
appl.c: In function 'errorp':
appl.c:5:9: warning: implicit declaration of function 'perror'; did you mean 'errorp'? [-Wimplicit-function-declaration]
    5 |         perror(msg);
      |         ^~~~~~
      |         errorp
appl.c:6:9: warning: implicit declaration of function 'exit' [-Wimplicit-function-declaration]
    6 |         exit(1);
      |         ^~~~
appl.c:1:1: note: include '<stdlib.h>' or provide a declaration of 'exit'
  +++ |+#include <stdlib.h>
    1 | #define BUFLEN 512
appl.c:6:9: warning: incompatible implicit declaration of built-in function 'exit' [-Wbuiltin-declaration-mismatch]
    6 |         exit(1);
      |         ^~~~
appl.c:6:9: note: include '<stdlib.h>' or provide a declaration of 'exit'
appl.c: In function 'main':
appl.c:11:28: error: storage size of 'server' isn't known
   11 |         struct sockaddr_in server, client;
      |                            ^~~~~~
appl.c:11:36: error: storage size of 'client' isn't known
   11 |         struct sockaddr_in server, client;
      |                                    ^~~~~~
appl.c:17:20: warning: implicit declaration of function 'socket' [-Wimplicit-function-declaration]
   17 |         if((sock = socket(AF_INET, SOCK_DGRAM, 0) == -1))
      |                    ^~~~~~
appl.c:17:27: error: 'AF_INET' undeclared (first use in this function)
   17 |         if((sock = socket(AF_INET, SOCK_DGRAM, 0) == -1))
      |                           ^~~~~~~
appl.c:17:27: note: each undeclared identifier is reported only once for each function it appears in
appl.c:17:36: error: 'SOCK_DGRAM' undeclared (first use in this function)
   17 |         if((sock = socket(AF_INET, SOCK_DGRAM, 0) == -1))
      |                                    ^~~~~~~~~~
appl.c:21:9: warning: implicit declaration of function 'printf' [-Wimplicit-function-declaration]
   21 |         printf("To the client: %s, %s", senbuf, " World");
      |         ^~~~~~
appl.c:1:1: note: include '<stdio.h>' or provide a declaration of 'printf'
  +++ |+#include <stdio.h>
    1 | #define BUFLEN 512
appl.c:21:9: warning: incompatible implicit declaration of built-in function 'printf' [-Wbuiltin-declaration-mismatch]
   21 |         printf("To the client: %s, %s", senbuf, " World");
      |         ^~~~~~
appl.c:21:9: note: include '<stdio.h>' or provide a declaration of 'printf'
appl.c:22:9: warning: implicit declaration of function 'bzero' [-Wimplicit-function-declaration]
   22 |         bzero(&server, sizeof(server));
      |         ^~~~~
appl.c:22:9: warning: incompatible implicit declaration of built-in function 'bzero' [-Wbuiltin-declaration-mismatch]
appl.c:26:34: warning: implicit declaration of function 'inet_addr' [-Wimplicit-function-declaration]
   26 |         server.sin_addr.s_addr = inet_addr("127.0.0.1");
      |                                  ^~~~~~~~~
appl.c:27:12: warning: implicit declaration of function 'bind' [-Wimplicit-function-declaration]
   27 |         if(bind(sock, (struct sockaddr*)&server, slen)==-1)
      |            ^~~~
appl.c:29:12: warning: implicit declaration of function 'recvfrom' [-Wimplicit-function-declaration]
   29 |         if(recvfrom(sock, recvbuf, sizeof(recvbuf), 0, (struct sockaddr*) &client, &clen) == -1)
      |            ^~~~~~~~
appl.c:33:12: warning: implicit declaration of function 'sendto' [-Wimplicit-function-declaration]
   33 |         if(sendto(sock, senbuf, sizeof(senbuf), 0, (struct sockaddr*) &client, sizeof(client)) == -1)
      |            ^~~~~~
appl.c:37:9: warning: implicit declaration of function 'close' [-Wimplicit-function-declaration]
   37 |         close(sock);
      |         ^~~~~
appl.c:11:36: warning: unused variable 'client' [-Wunused-variable]
   11 |         struct sockaddr_in server, client;
      |                                    ^~~~~~
appl.c:11:28: warning: unused variable 'server' [-Wunused-variable]
   11 |         struct sockaddr_in server, client;
      |                            ^~~~~~
```

## ソースコード２行追加
```c:appl.c
#include <stdio.h>
#include <stdlib.h>
```

## build and go

```ubuntu:bash
$ ./cg.sh appl
$ clang appl.c  -o appll -I. -Wall
appl.c:13:28: error: variable has incomplete type 'struct sockaddr_in'
        struct sockaddr_in server, client;
                           ^
appl.c:13:16: note: forward declaration of 'struct sockaddr_in'
        struct sockaddr_in server, client;
               ^
appl.c:13:36: error: variable has incomplete type 'struct sockaddr_in'
        struct sockaddr_in server, client;
                                   ^
appl.c:13:16: note: forward declaration of 'struct sockaddr_in'
        struct sockaddr_in server, client;
               ^
appl.c:19:20: warning: implicit declaration of function 'socket' is invalid in C99 [-Wimplicit-function-declaration]
        if((sock = socket(AF_INET, SOCK_DGRAM, 0) == -1))
                   ^
appl.c:19:27: error: use of undeclared identifier 'AF_INET'
        if((sock = socket(AF_INET, SOCK_DGRAM, 0) == -1))
                          ^
appl.c:19:36: error: use of undeclared identifier 'SOCK_DGRAM'
        if((sock = socket(AF_INET, SOCK_DGRAM, 0) == -1))
                                   ^
appl.c:24:9: warning: implicitly declaring library function 'bzero' with type 'void (void *, unsigned long)' [-Wimplicit-function-declaration]
        bzero(&server, sizeof(server));
        ^
appl.c:24:9: note: include the header <strings.h> or explicitly provide a declaration for 'bzero'
appl.c:26:29: error: use of undeclared identifier 'AF_INET'
        server.sin_family = AF_INET;
                            ^
appl.c:28:34: warning: implicit declaration of function 'inet_addr' is invalid in C99 [-Wimplicit-function-declaration]
        server.sin_addr.s_addr = inet_addr("127.0.0.1");
                                 ^
appl.c:29:12: warning: implicit declaration of function 'bind' is invalid in C99 [-Wimplicit-function-declaration]
        if(bind(sock, (struct sockaddr*)&server, slen)==-1)
           ^
appl.c:31:12: warning: implicit declaration of function 'recvfrom' is invalid in C99 [-Wimplicit-function-declaration]
        if(recvfrom(sock, recvbuf, sizeof(recvbuf), 0, (struct sockaddr*) &client, &clen) == -1)
           ^
appl.c:35:12: warning: implicit declaration of function 'sendto' is invalid in C99 [-Wimplicit-function-declaration]
        if(sendto(sock, senbuf, sizeof(senbuf), 0, (struct sockaddr*) &client, sizeof(client)) == -1)
           ^
appl.c:39:9: warning: implicit declaration of function 'close' is invalid in C99 [-Wimplicit-function-declaration]
        close(sock);
        ^
7 warnings and 5 errors generated.

$ gcc appl.c -o applg -I. -Wall
appl.c: In function 'main':
appl.c:13:28: error: storage size of 'server' isn't known
   13 |         struct sockaddr_in server, client;
      |                            ^~~~~~
appl.c:13:36: error: storage size of 'client' isn't known
   13 |         struct sockaddr_in server, client;
      |                                    ^~~~~~
appl.c:19:20: warning: implicit declaration of function 'socket' [-Wimplicit-function-declaration]
   19 |         if((sock = socket(AF_INET, SOCK_DGRAM, 0) == -1))
      |                    ^~~~~~
appl.c:19:27: error: 'AF_INET' undeclared (first use in this function)
   19 |         if((sock = socket(AF_INET, SOCK_DGRAM, 0) == -1))
      |                           ^~~~~~~
appl.c:19:27: note: each undeclared identifier is reported only once for each function it appears in
appl.c:19:36: error: 'SOCK_DGRAM' undeclared (first use in this function)
   19 |         if((sock = socket(AF_INET, SOCK_DGRAM, 0) == -1))
      |                                    ^~~~~~~~~~
appl.c:24:9: warning: implicit declaration of function 'bzero' [-Wimplicit-function-declaration]
   24 |         bzero(&server, sizeof(server));
      |         ^~~~~
appl.c:24:9: warning: incompatible implicit declaration of built-in function 'bzero' [-Wbuiltin-declaration-mismatch]
appl.c:28:34: warning: implicit declaration of function 'inet_addr' [-Wimplicit-function-declaration]
   28 |         server.sin_addr.s_addr = inet_addr("127.0.0.1");
      |                                  ^~~~~~~~~
appl.c:29:12: warning: implicit declaration of function 'bind' [-Wimplicit-function-declaration]
   29 |         if(bind(sock, (struct sockaddr*)&server, slen)==-1)
      |            ^~~~
appl.c:31:12: warning: implicit declaration of function 'recvfrom' [-Wimplicit-function-declaration]
   31 |         if(recvfrom(sock, recvbuf, sizeof(recvbuf), 0, (struct sockaddr*) &client, &clen) == -1)
      |            ^~~~~~~~
appl.c:35:12: warning: implicit declaration of function 'sendto' [-Wimplicit-function-declaration]
   35 |         if(sendto(sock, senbuf, sizeof(senbuf), 0, (struct sockaddr*) &client, sizeof(client)) == -1)
      |            ^~~~~~
appl.c:39:9: warning: implicit declaration of function 'close'; did you mean 'pclose'? [-Wimplicit-function-declaration]
   39 |         close(sock);
      |         ^~~~~
      |         pclose
appl.c:13:36: warning: unused variable 'client' [-Wunused-variable]
   13 |         struct sockaddr_in server, client;
      |                                    ^~~~~~
appl.c:13:28: warning: unused variable 'server' [-Wunused-variable]
   13 |         struct sockaddr_in server, client;
      |                            ^~~~~~
```
## ソースコード修正
   if((sock = socket(AF_INET, SOCK_DGRAM, 0) == -1))
を　
　　if (-1 == (sock = socket(AF_INET, SOCK_DGRAM, 0)))
に変更


## Build and go

```ubuntu:bash
# ./cg.sh appl
$ clang appl.c  -o appll -I. -Wall
appl.c:13:28: error: variable has incomplete type 'struct sockaddr_in'
        struct sockaddr_in server, client;
                           ^
appl.c:13:16: note: forward declaration of 'struct sockaddr_in'
        struct sockaddr_in server, client;
               ^
appl.c:13:36: error: variable has incomplete type 'struct sockaddr_in'
        struct sockaddr_in server, client;
                                   ^
appl.c:13:16: note: forward declaration of 'struct sockaddr_in'
        struct sockaddr_in server, client;
               ^
appl.c:18:20: warning: implicit declaration of function 'socket' is invalid in C99 [-Wimplicit-function-declaration]
        if (-1 == (sock = socket(AF_INET, SOCK_DGRAM, 0)))
                          ^
appl.c:18:27: error: use of undeclared identifier 'AF_INET'
        if (-1 == (sock = socket(AF_INET, SOCK_DGRAM, 0)))
                                 ^
appl.c:18:36: error: use of undeclared identifier 'SOCK_DGRAM'
        if (-1 == (sock = socket(AF_INET, SOCK_DGRAM, 0)))
                                          ^
appl.c:25:9: warning: implicitly declaring library function 'bzero' with type 'void (void *, unsigned long)' [-Wimplicit-function-declaration]
        bzero(&server, sizeof(server));
        ^
appl.c:25:9: note: include the header <strings.h> or explicitly provide a declaration for 'bzero'
appl.c:27:29: error: use of undeclared identifier 'AF_INET'
        server.sin_family = AF_INET;
                            ^
appl.c:29:34: warning: implicit declaration of function 'inet_addr' is invalid in C99 [-Wimplicit-function-declaration]
        server.sin_addr.s_addr = inet_addr("127.0.0.1");
                                 ^
appl.c:30:12: warning: implicit declaration of function 'bind' is invalid in C99 [-Wimplicit-function-declaration]
        if(bind(sock, (struct sockaddr*)&server, slen)==-1)
           ^
appl.c:32:12: warning: implicit declaration of function 'recvfrom' is invalid in C99 [-Wimplicit-function-declaration]
        if(recvfrom(sock, recvbuf, sizeof(recvbuf), 0, (struct sockaddr*) &client, &clen) == -1)
           ^
appl.c:36:12: warning: implicit declaration of function 'sendto' is invalid in C99 [-Wimplicit-function-declaration]
        if(sendto(sock, senbuf, sizeof(senbuf), 0, (struct sockaddr*) &client, sizeof(client)) == -1)
           ^
appl.c:40:9: warning: implicit declaration of function 'close' is invalid in C99 [-Wimplicit-function-declaration]
        close(sock);
        ^
7 warnings and 5 errors generated.

$ gcc appl.c -o applg -I. -Wall
appl.c: In function 'main':
appl.c:13:28: error: storage size of 'server' isn't known
   13 |         struct sockaddr_in server, client;
      |                            ^~~~~~
appl.c:13:36: error: storage size of 'client' isn't known
   13 |         struct sockaddr_in server, client;
      |                                    ^~~~~~
appl.c:18:27: warning: implicit declaration of function 'socket' [-Wimplicit-function-declaration]
   18 |         if (-1 == (sock = socket(AF_INET, SOCK_DGRAM, 0)))
      |                           ^~~~~~
appl.c:18:34: error: 'AF_INET' undeclared (first use in this function)
   18 |         if (-1 == (sock = socket(AF_INET, SOCK_DGRAM, 0)))
      |                                  ^~~~~~~
appl.c:18:34: note: each undeclared identifier is reported only once for each function it appears in
appl.c:18:43: error: 'SOCK_DGRAM' undeclared (first use in this function)
   18 |         if (-1 == (sock = socket(AF_INET, SOCK_DGRAM, 0)))
      |                                           ^~~~~~~~~~
appl.c:25:9: warning: implicit declaration of function 'bzero' [-Wimplicit-function-declaration]
   25 |         bzero(&server, sizeof(server));
      |         ^~~~~
appl.c:25:9: warning: incompatible implicit declaration of built-in function 'bzero' [-Wbuiltin-declaration-mismatch]
appl.c:29:34: warning: implicit declaration of function 'inet_addr' [-Wimplicit-function-declaration]
   29 |         server.sin_addr.s_addr = inet_addr("127.0.0.1");
      |                                  ^~~~~~~~~
appl.c:30:12: warning: implicit declaration of function 'bind' [-Wimplicit-function-declaration]
   30 |         if(bind(sock, (struct sockaddr*)&server, slen)==-1)
      |            ^~~~
appl.c:32:12: warning: implicit declaration of function 'recvfrom' [-Wimplicit-function-declaration]
   32 |         if(recvfrom(sock, recvbuf, sizeof(recvbuf), 0, (struct sockaddr*) &client, &clen) == -1)
      |            ^~~~~~~~
appl.c:36:12: warning: implicit declaration of function 'sendto' [-Wimplicit-function-declaration]
   36 |         if(sendto(sock, senbuf, sizeof(senbuf), 0, (struct sockaddr*) &client, sizeof(client)) == -1)
      |            ^~~~~~
appl.c:40:9: warning: implicit declaration of function 'close'; did you mean 'pclose'? [-Wimplicit-function-declaration]
   40 |         close(sock);
      |         ^~~~~
      |         pclose
appl.c:13:36: warning: unused variable 'client' [-Wunused-variable]
   13 |         struct sockaddr_in server, client;
      |                                    ^~~~~~
appl.c:13:28: warning: unused variable 'server' [-Wunused-variable]
   13 |         struct sockaddr_in server, client;
      |                            ^~~~~~
```