I everyone, I have two C Socket questions. I have searched the net and read my reference books, but cannot find my answer.

Anyway, I am making a simple telnet based server. To create a new socket I am using the following code:

newsockfd = accept(sockfd, (struct sockaddr *) &cli_addr, &clilen);

... and I get the following error: warning: pointer targets in passing argument 3 of 'accept' differ in signedness.

sockfd was declared as an "int."
cli_addr was declared as "struct sockaddr_in cli_addr;"
clilen was delcared as "clilen = sizeof(cli_addr);"

Of corse, my program compiles and runs fine, but I just cannot shake that darn warning.

Now, my second question is hopfully simple. The way I have my server setup it only accepts packets after the other end has sent a CR. But, I need to read each caracter the client types on the keyboard. How do I setup my socket to read every key instead of a packet after a CR?

If you could please help point me into the right direction. Thanks!

-Matt

:rolleyes:

... and I get the following error: warning: pointer targets in passing argument 3 of 'accept' differ in signedness.

sockfd was declared as an "int."
cli_addr was declared as "struct sockaddr_in cli_addr;"
clilen was delcared as "clilen = sizeof(cli_addr);"

What is the type of clilen? From the man pages I've quickly searched, it would appear that it is supposed to be a socklen_t. Is it? Or is it perhaps an int?

Ah.. Duh! That was it. It's always the simple things I dont catch.

Thanks again! :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.