DANDY King wrote:
hello
our product is DVR(digital video recorder), it runs on linux system.
i am sending very imp inofrmation to server through sockets. some time i
am getting full data, some time i am getting partial data.
i don't know reasons please advice.
client side we uses VC++ GUI. client sending data neatly. in lcinet
side what i did
while((nread = read(fd,buff,BUFFSIZE)) >0)
send(sockfd,buff,nread,0);
in server same data should receive.
but some time i am receiveing full and some time 90% only
Are you aware that the send() function could queue less data
than requested? The better loop would look like:
while((nread = read(fd, buff, BUFFSIZE)) > 0) {
ssize_t sent;
char *b = buff;
while(nread > 0) {
sent = send(sockfd, b, nread, 0);
if(sent > 0) {
nread -= sent;
b += sent;
} else {
/* Handle "can't send" case */
break;
}
}
}
please advice
Dharanish
_________________________________________________________________
Are you a geek? Do gizmos make you grin?
http://www.msn.co.in/Computing/Gizmos/ Click here!
_______________________________________________
[EMAIL PROTECTED] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-net
To unsubscribe, send any mail to "[EMAIL PROTECTED]"
--
Lev Walkin
[EMAIL PROTECTED]
_______________________________________________
[EMAIL PROTECTED] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-net
To unsubscribe, send any mail to "[EMAIL PROTECTED]"