Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 19 Aug 2003 12:14:50 -0700
From:      Lev Walkin <vlm@netli.com>
To:        DANDY King <dandyking_18@hotmail.com>
Cc:        freebsd-net@freebsd.org
Subject:   Re: help
Message-ID:  <3F42772A.9000106@netli.com>
In-Reply-To: <BAY1-F160aU83i9IiUS0001e4d8@hotmail.com>
References:  <BAY1-F160aU83i9IiUS0001e4d8@hotmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3F42772A.9000106>