diff options
Diffstat (limited to 'client/net/net.c')
| -rw-r--r-- | client/net/net.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/client/net/net.c b/client/net/net.c new file mode 100644 index 0000000..be61104 --- /dev/null +++ b/client/net/net.c @@ -0,0 +1,26 @@ +#include <stdio.h> +#include <stdlib.h> +#include <err.h> +#include <sys/socket.h> +#include <unistd.h> +#include <netinet/in.h> +#include <time.h> +#include "net.h" + +void ServerConnect() { + int fd = socket(AF_INET, SOCK_DGRAM, 0); + + if (fd == -1) + err(EXIT_FAILURE, "socket failed"); + + char buff[64]; + + struct sockaddr_in server; + server.sin_family = AF_INET; + server.sin_port = htons(8080); + server.sin_addr.s_addr = htonl(INADDR_LOOPBACK); + + sendto(fd, buff, sizeof(buff), 0, (struct sockaddr *)&server, sizeof(server)); + + close(fd); +} |