sockets - select() call with infinit timeout -


i want use select call send() data write socket fd. going ue non blocking socket implemenation. implementation better.

while(u4bytessent < u2buflen) {      i4retval = send(sockfd, au1buf + u4bytessent, (u2buflen - u4bytessent));     if(i4restval == -1 && errno != ewouldblock)     {         break;     }     i4bytessent = i4bytessent + i4retval;    } 

will code hog cpu if send buffer becomes full frequently?

or

use select call infinite timeout.will select() have better performance cpu hogging , all?

will code hog cpu if send buffer becomes full frequently?

yes. behave incorrectly (most crash), end adding error return value of -1 i4bytessent repeatedly on error.

using select() infinite (or, @ least, long) timeout should work fine. process sleep until data available on socket.

given you're describing, better off not using non-blocking sockets. there's no point if you're going wrap them in select() make write operations blocking anyway!


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -