LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 03-06-2002, 03:11 PM   #1
The Bag
LQ Newbie
 
Registered: Dec 2001
Distribution: Mandrake, Red Hat, Windows XP Pro
Posts: 14

Rep: Reputation: 0
C Help!!!!!!!!!!


Can someone please tell me whats wrong with this code. It's for a simple proxy server and when I compile it with gcc -c -ansi -pedantic ... I get the error message: sock.c: In function `main':
sock.c:41: warning: pointer targets in passing arg 3 of `accept' differ in signedness
which relates to the accept() command.

------------------------------------------------------------------------------------
PHP Code:
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>

#define BACKLOG 1

main(){

  
struct sockaddr_in client_add;
  
struct sockaddr_in my_add;
  
int portnum 8080;
  
char myname[50];
  
int sockfdinsock;
  
int sin_size;

  
gethostname(myname50);
  
printf("started\n");

  
my_add.sin_family AF_INET;
  
my_add.sin_port htons(portnum);
  
my_add.sin_addr.s_addr INADDR_ANY;
  
memset(&(my_add.sin_zero), '\0',8);

  
sockfd socket(AF_INETSOCK_STREAM,0);


  if((
bind(sockfd, (struct sockaddr *)&my_addsizeof(struct sockaddr))) < 0){
    
printf("dead\n");
  }else{
    
printf("bound\n");
  }

  if((
listen(sockfdBACKLOG)) < 0){
    
printf("dies on listen");
  }else{
    
printf("listening\n");
  }

  
sin_size sizeof(struct sockaddr_in);
  
insock accept(sockfd, (struct sockaddr *)&client_add, &sin_size);


 
Old 03-06-2002, 03:17 PM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
i'd assume it's because you're define sin_whatever as a standard signed int, when maybe it wan't and unsigned int. try adding "unsigned" before the int declaration.
 
Old 03-06-2002, 05:18 PM   #3
The Bag
LQ Newbie
 
Registered: Dec 2001
Distribution: Mandrake, Red Hat, Windows XP Pro
Posts: 14

Original Poster
Rep: Reputation: 0
that was it thanks.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:26 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration