UNIX Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsOperating SystemsUNIX Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old May 12th, 2006, 09:46 AM
rajkhowa rajkhowa is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2006
Posts: 2 rajkhowa User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 30 m 30 sec
Reputation Power: 0
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;
}

Reply With Quote
Reply

Viewing: Dev Shed ForumsOperating SystemsUNIX Help > Blocking read/write roblem in socket


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway