int main(int argc, char *argv)
{
int sfd;
int new_fd;
int port;
pthread_t pid;
port = PORT;
head = (Link)malloc(sizeof(Online));
head->next = NULL;
if(sqlite3_open("data.db", &db) != SQLITE_OK)
{
perror("open error:");
exit(1);
}
if(sqlite3_open("record.db", &record) != SQLITE_OK)
{
perror("open error:");
exit(1);
}
sfd = tcp_init(port);
while(1)
{
printf("Sever waiting...\n");
new_fd = tcp_accept(sfd);
pthread_create(&pid, NULL, (void *)log_handle, (void *)&new_fd);
}
pthread_join(pid, NULL);
sqlite3_close(db);
sqlite3_close(record);
return 0;
}
{
int sfd;
int new_fd;
int port;
pthread_t pid;
port = PORT;
head = (Link)malloc(sizeof(Online));
head->next = NULL;
if(sqlite3_open("data.db", &db) != SQLITE_OK)
{
perror("open error:");
exit(1);
}
if(sqlite3_open("record.db", &record) != SQLITE_OK)
{
perror("open error:");
exit(1);
}
sfd = tcp_init(port);
while(1)
{
printf("Sever waiting...\n");
new_fd = tcp_accept(sfd);
pthread_create(&pid, NULL, (void *)log_handle, (void *)&new_fd);
}
pthread_join(pid, NULL);
sqlite3_close(db);
sqlite3_close(record);
return 0;
}