Hi all,
in an attempt to exercise my socket programming/class writing skills, i have come accros a small problem in the class i am delevoping - it just a simple socket/server class under Unix (BSD).
my class is nothing to fancy and is derived from an old socket server/client program that i have basically split into parts, and each 'part' then becomes a class method. e.g. mySoc.establish, mySoc.Bind, mySoc.getConnection. I have a few class instance variable used to keep track of various info about the client/server socket.
the problem arrises in the server class, in my accecpt method. The server class is designed to accept multiple connections (5 max). Now, im trying to retrieve some client info from the socket once it has been accepted, only ,when i compile the server application i get the following error:
SocketClass.h:169: passing `int *' as argument 3 of `accept(int, sockaddr *, socklen_t *)' changes signedness
my class method is as follows :
[Red]
int SocketServerClass::getConnection(int s)
{
int t; /* new socket for connection */
int sin_size;
struct sockaddr_in client; /* client's address */
sin_size = sizeof(struct sockaddr_in);
if ((t = accept(s, (struct sockaddr *)&client, &sin_size))==-1){ /* accept connection if there is one */
return(-1);
}
printf("You got a connection from %s\n",inet_ntoa(client.sin_addr) ); /* prints client's IP */
return(t);
}[/Red]
Firstly, i have no idea what signedness means, or why argument 3 of accept changes it!! I have checked the code, and other socket code i found on the net - the use of socket accept is exactly the same, except when supporting a single connection, in which case [Blue]t = accept(s, (struct sockaddr *)&client, &sin_size)[/Blue] is used. I can also run the original console application without any probs.
Does anyone know what this error means, or why i might be getting it? By the way, the original socket code in the console app was [Blue]if ((t = accept(s,NULL,NULL)) < 0)[/Blue], but of course, this does not use sockaddr_in and so no socket info is provided, however, it does accept multiple sockets as expected.
Any explanation would be good at this stage, cos i think i'm going mad!
Thanks in advance, regards,
j@Yb0t
"Always know what you say, but don't always say what you know!"
in an attempt to exercise my socket programming/class writing skills, i have come accros a small problem in the class i am delevoping - it just a simple socket/server class under Unix (BSD).
my class is nothing to fancy and is derived from an old socket server/client program that i have basically split into parts, and each 'part' then becomes a class method. e.g. mySoc.establish, mySoc.Bind, mySoc.getConnection. I have a few class instance variable used to keep track of various info about the client/server socket.
the problem arrises in the server class, in my accecpt method. The server class is designed to accept multiple connections (5 max). Now, im trying to retrieve some client info from the socket once it has been accepted, only ,when i compile the server application i get the following error:
SocketClass.h:169: passing `int *' as argument 3 of `accept(int, sockaddr *, socklen_t *)' changes signedness
my class method is as follows :
[Red]
int SocketServerClass::getConnection(int s)
{
int t; /* new socket for connection */
int sin_size;
struct sockaddr_in client; /* client's address */
sin_size = sizeof(struct sockaddr_in);
if ((t = accept(s, (struct sockaddr *)&client, &sin_size))==-1){ /* accept connection if there is one */
return(-1);
}
printf("You got a connection from %s\n",inet_ntoa(client.sin_addr) ); /* prints client's IP */
return(t);
}[/Red]
Firstly, i have no idea what signedness means, or why argument 3 of accept changes it!! I have checked the code, and other socket code i found on the net - the use of socket accept is exactly the same, except when supporting a single connection, in which case [Blue]t = accept(s, (struct sockaddr *)&client, &sin_size)[/Blue] is used. I can also run the original console application without any probs.
Does anyone know what this error means, or why i might be getting it? By the way, the original socket code in the console app was [Blue]if ((t = accept(s,NULL,NULL)) < 0)[/Blue], but of course, this does not use sockaddr_in and so no socket info is provided, however, it does accept multiple sockets as expected.
Any explanation would be good at this stage, cos i think i'm going mad!
Thanks in advance, regards,
j@Yb0t
"Always know what you say, but don't always say what you know!"