Re: Repost: OpenTransport problems under X [solved]
Re: Repost: OpenTransport problems under X [solved]
- Subject: Re: Repost: OpenTransport problems under X [solved]
- From: Marc Stibane <email@hidden>
- Date: Thu, 27 Nov 2003 16:07:56 +0100
>
>IMHO it should return the moment any data is/becomes available, and after
>
>the timeout it should return 0.
>
>
That's right. Given that select gets a serious workout by numerous
>
parts of the system, I think it's unlikely (although not impossible)
>
that this is a system bug. Can you post a snippet that shows how you
>
call select?
for (r = 0; r < mHeight; r++) {
...
bytes_read = Scan_ReadImageBuffer(s_conn, buf, mScanlineWidth);
if (bytes_read > 0) {
/*** copy scanline into bits buffer **/
...
}
...
} // for
int
Scan_ReadImageBuffer(SOCKET skt,char * buf,int b_len)
{
int rd = 0;
int ret;
int sleep_cnt = 0;
fd_set rfds;
struct timeval tv;
while(rd < b_len){
FD_ZERO(&rfds);
FD_SET(skt,&rfds);
tv.tv_sec = 1; // 1 second timeout
tv.tv_usec = 0;
ret = select(1,&rfds,NULL,NULL,&tv);
if(ret > 0) {
ret = recv(skt,&buf[rd],b_len - rd,0);
if(ret > 0)
rd+=ret;
else
return rd; // Maybe connection is closed
} else {
sleep_cnt++;
if(sleep_cnt > 5) // 5 seconds
return rd;
}
} // while()
return rd;
}
Marc Stibane
Fesh! email@hidden
Kurf|rstenstr. 154 tel +49-30-3990 2690
10785 Berlin, Germany mobil +49-173-6522 422
In a world without walls and fences,
who needs windows and gates?
_______________________________________________
macnetworkprog mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/macnetworkprog
Do not post admin requests to the list. They will be ignored.