|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Blocking read/write roblem in socket
hi guys...i am developing a message passing application using unix sockets....but the blocking nature of read/write functions is giving lot of problem...the server will keep listening for conections and when a client connects it sends to the client the list of already logged clients...i have used a structure to keep this list....but in the client this list is not getting printed...here is the code...thanx
server(after accept) ---------------------- for(; ![]() { rset = allset; nready = select(maxfd + 1, &rset, NULL, NULL, NULL); if (FD_ISSET(listenfd, &rset)) { printf("hi in accept\n"); clientlen = sizeof(cliaddr); connfd = accept(listenfd, (struct sockaddr *) &cliaddr, &clientlen); printf("\nServer : Got connection from %s on descriptor \t%d",inet_ntoa(cliaddr.sin_addr),connfd); read(connfd,input,255); strcpy(store[no].name,input); store[no].fd = connfd; no++; for(i=0;i<no;i++) write(connfd,store[i].name,4096); for(i=0;i<FD_SETSIZE;i++) { if (client[i] < 0) { client[i] = connfd; break; } } FD_SET(connfd, &allset); if (connfd > maxfd) maxfd = connfd; if (i > maxi) maxi = i; if (--nready <= 0) continue; } client (after connect) ------------------------ if (connect(sockfd, (struct sockaddr *)&their_addr,sizeof(struct sockaddr)) == -1) { perror("connect"); exit(1); } write(sockfd,buf2,MAX); while(1) { num = read(sockfd,buf,4096); printf("%s",buf); if(num<=0)break; } |
![]() |
| Viewing: Dev Shed Forums > Operating Systems > UNIX Help > Blocking read/write roblem in socket |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|