Article View: news.software.nntp
Article #78834Re: AUTHINFO problem
From: Xavier Roche
Date: Sun, 16 Mar 2008 14:07
Date: Sun, 16 Mar 2008 14:07
34 lines
2576 bytes
2576 bytes
Niz a Γ©crit :
> send(sock, loginName, sizeof(loginName), 0);
> recv(sock, buffer, bufsize, 0);
Humm, this is not a protocol issue, and this is IMHO off-topic in
news.software.nntp, but anyway you should:
- careflly check and handle the send/recv returncode(s) (man recv and
man send)
- loop until recv() a complete line, because there is no guarantee that
the reply will be received at once ("The receive calls normally return
any data available, up to the requested amount, rather than waiting
for receipt of the full amount requested.")
using something like (typo/syntax not checked):
int readLine((int sock, char *buffer, size_t bufsize) {
ssize_t ret, size;
for(size = 0 ; size < buffsize && (ret = recv(sock, buffer + size,
bufsize - size, 0)) >=0 ; size += ret) {
/* loop until end of line reached */
if (size > 2 && buffer[size - 2] == '\r' && buffer[size - 1] == '\n') {
break;
}
}
return (ret >= 0 && size < buffsize); /* ok ? */
}
..
if (readLine(sock, buffer, bufsize)) {
..
} else {
.. error handling
}
Technical Details
Message-ID:
<frj9i0$mmf$2@news.httrack.net>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.20141118.mbox.gz!number1.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!t-online.de!newsfeed.freenet.de!feeder2.ecngs.de!ecngs!feeder.ecngs.de!news.osn.de!diablo2.news.osn.de!212.27.60.9.MISMATCH!feeder2-2.proxad.net!proxad.net!feeder1-2.proxad.net!exabot.com!porbandar.httrack.net!montbard.httrack.net!news.httrack.net!not-for-mailReferences:
<2008031611435716807-niz@nicetrycom> <frj1aj$7rt$1@news.trigofacile.com> <2008031613051775249-niz@nicetrycom> <frj662$mmf$1@news.httrack.net> <2008031613334150073-niz@nicetrycom>Show Full Headers
Complete Article Headers
Message-ID: <frj9i0$mmf$2@news.httrack.net> Subject: Re: AUTHINFO problem Date: Sun, 16 Mar 2008 15:07:07 +0100 From: Xavier Roche <xroche@free.fr.NOSPAM.invalid> References: <2008031611435716807-niz@nicetrycom> <frj1aj$7rt$1@news.trigofacile.com> <2008031613051775249-niz@nicetrycom> <frj662$mmf$1@news.httrack.net> <2008031613334150073-niz@nicetrycom> Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.20141118.mbox.gz!number1.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!t-online.de!newsfeed.freenet.de!feeder2.ecngs.de!ecngs!feeder.ecngs.de!news.osn.de!diablo2.news.osn.de!212.27.60.9.MISMATCH!feeder2-2.proxad.net!proxad.net!feeder1-2.proxad.net!exabot.com!porbandar.httrack.net!montbard.httrack.net!news.httrack.net!not-for-mail Newsgroups: news.software.nntp Organization: Nowhere Corp. Lines: 34 NNTP-Posting-Host: machine-1.localnet Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit X-Trace: news.httrack.net 1205676416 23247 192.168.1.1 (16 Mar 2008 14:06:56 GMT) X-Complaints-To: usenet@httrack.com NNTP-Posting-Date: Sun, 16 Mar 2008 14:06:56 +0000 (UTC) User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; fr-FR; In-Reply-To: <2008031613334150073-niz@nicetrycom>