I tried that and it compiled for me, but mine still doesn't...
I will post some trimmed down files for you, because it sounds like I am overlooking something here:
Sorry for the long post.
main.c
Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "linsock.h"
int main (void)
{
struct linfo info;
memset(&info, 0, sizeof(struct linfo));
info.host = "google.com";
info.port = 80;
info.timeout = 5;
printf("Attempting to connect to %s on port %d\n", info.host, info.port);
lconnect(&info);
if (info.fsock)
{
printf("Connected\n");
pthread_create(&(info.tid), NULL, lreceive, (void *)&info);
pthread_join(info.tid, NULL);
}
else
{
printf("%s\n", strerror(errno));
}
close(info.fsock);
return 0;
}
linsock.c
Code:
#include "linsock.h"
void lconnect (struct linfo *info)
{
/*
Yadda Yadda Yadda
*/
}
void *lreceive (void *params)
{
struct linfo *info = (struct *linfo)params;
int result = 1;
char *buffer = malloc(2048 * sizeof(char));
while (result)
{
result = recv(info->fsock, buffer, 2048, 0);
if (result)
{
printf("%d bytes received\n");
}
else
break;
}
return NULL;
}
void lresolve (struct linfo *info)
{
/*
Yadda Yadda Yadda
*/
}
linsock.h
Code:
#ifndef _LINSOCK_H_
#define _LINSOCK_H_
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <fcntl.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <pthread.h>
#include <sys/socket.h>
#include <unistd.h>
#include <netinet/in.h>
#include <netdb.h>
#include <arpa/inet.h>
#include <errno.h>
struct linfo
{
int fsock;
char *host;
char *ip;
short port;
int timeout;
struct sockaddr_in service;
pthread_t tid;
};
void lresolve (struct linfo *info);
void lconnect (struct linfo *info);
void *lreceive (void *params);
#endif