Hello,
I'm trying to get this process to run in the background, and create a thread. 
currently, it just starts and stops... any ideas?
I'm using what I found on google, which doesn't seem to be working.


#include "vertigo.h"
#include "server.h"

//this is what holds the connection for the user.
struct User
{
int Connection;
sockaddr Address;
unsigned int AddressSize;
};

int main(void)
{
pid_t child;
child=fork(); //yay, we're a demon.
if (child<0)
{
return 1;
}
exit(0);
setsid();
pthread_t LThread;
pthread_create(&LThread,NULL,Listener,NULL);
for (int i=0;i<10;i++)
{
close(i);
}
while (1)
{
}
return 0;
}

void* Listener(void* arg)
{
int sock;
vector <User*> users;
sockaddr_in addr;
sock=socket(PF_INET,SOCK_STREAM,IPPROTO_TCP);
if (sock<0)
{
return NULL;
}
memset(&addr,0,sizeof(addr));
addr.sin_family=AF_INET;
addr.sin_addr.s_addr=htonl(INADDR_ANY);
addr.sin_port=htons(3306);
if (bind(sock,(sockaddr*)&addr,sizeof(addr))<0)
{
return NULL;
}
listen(sock,32);
User *client=NULL;
while (1)
{
client=new User();
memset(client,0,sizeof(User));
client->AddressSize=sizeof(sockaddr);
accept(sock,&client->Address,&client->AddressSize);
users.push_back(client);
}
close(sock);
return NULL;
}



Thanks,
_|_|_|_|_|  _|        _|_|_|_|            
    _|      _|_|_|    _|          _|_|_|  
    _|      _|    _|  _|_|_|    _|        
    _|      _|    _|  _|        _|        
    _|      _|    _|  _|_|_|_|    _|_|_|  
Visit TDS for quality software and website production
http://tysdomain.com
msn: [EMAIL PROTECTED]
aim: st8amnd2005
skype: st8amnd127

[Non-text portions of this message have been removed]

Reply via email to