- #1
James889
- 192
- 1
Hi,
I have a simple tcp server, to which i would like to add support for multiple client connections via pthreads. This is what i had in mind, calling accept in a separate thread.
I this similar to what you would do?
I have a simple tcp server, to which i would like to add support for multiple client connections via pthreads. This is what i had in mind, calling accept in a separate thread.
I this similar to what you would do?
Code:
.
.
.
int sock = socket(PF_INET,SOCK_STREAM,0);
int sock_fd[10];
struct sockaddr_in client_addr[10];
int size = sizeof(&client_addr);
void *Thread1(void *arg){
for(i=0;i<9;i++){
sock_fd[i] = accept(sock,(struct sockaddr *)&client_addr[i],size);
}