Re: help
From: Lev Walkin (vlm_at_netli.com)
Date: 08/19/03
- Previous message: DANDY King: "help"
- In reply to: DANDY King: "help"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Tue, 19 Aug 2003 12:14:50 -0700 To: DANDY King <dandyking_18@hotmail.com>
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!
>
> _______________________________________________
> freebsd-net@freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-net
> To unsubscribe, send any mail to "freebsd-net-unsubscribe@freebsd.org"
-- Lev Walkin vlm@netli.com _______________________________________________ freebsd-net@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-net To unsubscribe, send any mail to "freebsd-net-unsubscribe@freebsd.org"
- Previous message: DANDY King: "help"
- In reply to: DANDY King: "help"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|