Good Morning,
I am trying to compile some c code (which compiled on Fedora Core 4 and CentOS) but now wont compile on Ubuntu.... This is the following error I am getting when I try to compile and I have alos posted the source code. Any Ideas?
lyoussef@lyoussef:~/Desktop/working code$ gcc chats.c
chats.c: In function ‘main’:
chats.c:55: warning: pointer targets in passing argument 3 of ‘accept’ differ in signedness
/tmp/ccJ5AgRk.o: In function `main':chats.c
.text+0x8f): undefined reference to `passivesock'
collect2: ld returned 1 exit status
*** SOURCE ***
Code:
/* Wait for someone to chat with you */
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/time.h>
#include <netinet/in.h>
#include "sock.h"
#define QLEN 0
#define BUFSIZE 4096
extern int errno;
//extern char *sys_errlist[];
int main( int argc, char *argv[] )
{
char *service;
int rport = 0;
struct sockaddr_in fsin;
int alen;
int sd, ssock;
int n;
char buffer[BUFSIZE];
switch (argc)
{
case 1:
rport = 1;
break;
case 2:
service = argv[1];
break;
default:
//errexit( "usage: chatd [port]\n" );
printf("usuage: chatd [port]\n");
exit (-1);
}
/* Create the server socket */
sd = PASSIVE_TCP( service, QLEN, &rport );
if (rport)
{
/* Tell the user the selected port */
printf( "chatd: port %d\n", rport );
fflush( stdout );
}
/* Wait for someone to show up and then establish a connection with them */
alen = sizeof(fsin);
ssock = accept(sd, (struct sockaddr *)&fsin, &alen );
if (ssock < 0)
// errexit("accept: %s\n", sys_errlist[errno]);
exit (-1);
/* Take turns with your partner */
/* Enter "Q" to quit */
for (;;)
{
if ( (n = read( ssock, buffer, BUFSIZE )) > 0 )
{
/* printf( "Got a buffer." ); */
;
}
else
{
close( ssock );
break;
}
}
close( sd );
}