I am making a chat server which accepts connections by telnet. I have the basic body of it down and when I compile it I get this error
Code:
In file included from sh0ck.c:1:
list.h: In function `connector':
list.h:194: error: request for member `sin_addr' in something not a structure or union
Which pertains to this function
Code:
int connector(int socket, struct sockaddr *client, int fdmax, fd_set *set )
{
int addrlen;
int newfd;
addrlen = sizeof(struct sockaddr);
if ((newfd = accept(socket, (struct sockaddr *)&client, &addrlen)) == -1)
{
perror("accept");
return -1;
}
else
{
FD_SET(newfd, set);
if (newfd > fdmax)
fdmax = newfd;
printf("sh0ck: new connection from %s on socket %d\n",
inet_ntoa(client.sin_addr), newfd);
}
return newfd;
}
I know that it has something to do with passing the structure to the funtion, I'm just unclear as to what it is.
This is how I am calling the function
Code:
if ((newfd = connector( sockfd, (struct sockaddr *)&client, fdmax, &master))==-1)
{
perror("connector");
close(newfd);
}