Fixed deprecated bzero and bcopy calls

This commit is contained in:
Mark Qvist 2020-06-24 14:28:50 +02:00
parent 07eeed45f5
commit 671ea5dda0
1 changed files with 2 additions and 4 deletions

6
TCP.c
View File

@ -11,17 +11,15 @@ int open_tcp(char* ip, int port) {
struct hostent *server;
struct sockaddr_in serv_addr;
server = gethostbyname(ip);
if (server == NULL) {
perror("Error resolving host");
exit(1);
}
bzero((char *) &serv_addr, sizeof(serv_addr));
memset(&serv_addr, 0, sizeof(serv_addr));
serv_addr.sin_family = AF_INET;
bcopy((char *)server->h_addr, (char *)&serv_addr.sin_addr.s_addr, server->h_length);
memcpy(server->h_addr, &serv_addr.sin_addr.s_addr, server->h_length);
serv_addr.sin_port = htons(port);
if (connect(sockfd, (struct sockaddr*)&serv_addr, sizeof(serv_addr)) < 0) {