Hi,
I'm writing an NNTP based program that downloads articles from Usenet.
I've run into a weird problem. It seems as if there is a bug somewhere
that causes certain articles to download incorrectly (just by a byte or
two). It happens to the same articles and about 1 out of 5 have issues. So
everything seems to work ok, but somewhere something causes this weird
behavior.
The code that should work but doesn't (sometimes) downloads an article and
returns it.
Any help would be appreciated.
Matta
- - - - -
string NNTP::net_recv( )
{
int numbytes;
string buffer;
char buf[MAXDATASIZE];
numbytes = recv(sockfd, buf, MAXDATASIZE-1, 0);
if (numbytes < 1) {
return "";
}
buf[numbytes] = '\0';
buffer = buf;
return buffer;
}
extern "C" string NNTP::get_artic le(string msgid)
{
string rdata, sendstr, tmp;
string::size_ty pe pos;
sendstr = "ARTICLE ";
sendstr += msgid;
sendstr += "\r\n";
net_send(sendst r);
rdata = "";
do {
rdata += net_recv();
} while (rdata.substr(r data.length()-5, 5) != "\r\n.\r\n" );
rdata = rdata.substr(0, rdata.length() - 3);
pos = rdata.find("\r\ n\r\n", 0);
rdata = rdata.substr(po s + 4, rdata.length() - (pos + 4));
if (rdata.substr(0 , 2) == "..") {
rdata.erase(0, 1);
}
pos = 0;
while ((pos = rdata.find("\r\ n..", pos)) != string::npos) {
rdata.erase(pos + 2, 1);
}
return rdata;
} 3 1243
Matta <ma***@use.ne t> wrote in
news:pa******** *************** *****@use.net: I'm writing an NNTP based program that downloads articles from Usenet. I've run into a weird problem. It seems as if there is a bug somewhere that causes certain articles to download incorrectly (just by a byte or two). It happens to the same articles and about 1 out of 5 have issues. So everything seems to work ok, but somewhere something causes this weird behavior.
The code that should work but doesn't (sometimes) downloads an article and returns it.
Any help would be appreciated.
Matta
- - - - -
string NNTP::net_recv( ) {
This is C++ code, not C code, and it's a networking question (probably)
which is outside the scope of comp.lang.c++. Regardless, it's off-topic
here.
--
- Mark ->
--
In article <pa************ *************** *@use.net>,
Matta <ma***@use.ne t> wrote:
Your program appears to be in C++, not C. And you'll probably also
be flamed for asking about code that uses system-specific socket
functions.
As a general debugging hint, I suggest you start by separating out the
socket code from the text processing code. Put one of the failing
articles in a file and read it from there, so you don't have to worry
about the network aspect.
-- Richard
Matta wrote:
.... snip ... The code that should work but doesn't (sometimes) downloads an article and returns it.
The code you posted is in C++ (which is OffTopic here) and also
contains calls to non-standard C functions. You need a newsgroup
that deals with your particular system. Here we deal only with
portable C compliant with the ISO standard.
--
A: Because it fouls the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail? This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Nathan Davis |
last post by:
Hi,
I am having problems reading data from a socket. The problem only
occurs while trying to read from one particular server, and does not
occur on Windows (as far as I know, this may occur only on Linux).
The server is free.teranews.com, and I am trying to connect to the NNTP
port (119). To make things even more bizar, I only have trouble when I
try to issue the LIST command. After issuing the command, Java will not
return any...
|
by: Krzysztof Pa¼ |
last post by:
Hi,
I want to make simple client in phyton, which would be able to communicate
with Java server using SSL sockets.
There is the Java clients, which is doing this - so I'm pretty sure, that
Java server works OK.
I've heard, that P2.3 has SSL support included in himself and also, I was
trying P2.2 with pyOpenSSL wrappers and extensions, but unsuccesfuly...
So, could you give me a few lines of python code which makes such things:
|
by: Mahesh Devjibhai Dhola [MVP] |
last post by:
Hi,
Socket class documentation says that it is not thread safe. We understand
that if do simultaneous sends on ONE socket then it will be a problem (or
simultaneous receive). Can we create TWO threads on OUR OWN such that one
will do SEND and one will do RECEIVE using the SAME socket reference? This
means that two threads WILL BE in the same SOCKET object - one doing receive
and one doing send. We know we can use asynchronous calls on...
|
by: Phil Jenson |
last post by:
I am try to evaluate the most efficient method of handling thousands of
simultaneous TCP connects each of which remain connected to the server for
hours and pass a small amount of data usually once a minute. The data
received is logged in a SQL Server database.
The only method I have found of reading each socket requires a thread for
each connection which blocks waiting for data. This appears to be very
inefficient as it will result in...
|
by: Morten |
last post by:
How do I detect if a client socket is no longer connected to the listen tcp
socket ?
I have tried with (just an example):
---------------------
Socket tcpSocket;
while(tcpSocket.Connected)
| |
by: Thomas Lerchner |
last post by:
Hi!
I have a problem with an UDP socket.
I create socket and call BeginReceiveFrom to use the socket async.
But the callback methode is being called several times with the same packet
from the same sender.
It has been confirmed that the data was sent only once.
I used a sniffer to debug that.
And it does not matter if the data is broadcasted or sent to specific
address.
|
by: mscirri |
last post by:
The code below is what I am using to asynchronously get data from a
PocketPC device. The data comes in fine in blocks of 1024 bytes but
even when I send no data from the PocketPC constant blocks of 1024 with
all values set to Null arrive. Other than examine a block of 1024 to
see if the entire block is null, is there any other way to determine if
, say a chat message "Hi Charlie" has been received completely?
|
by: coloradowebdev |
last post by:
i am working on basically a proxy server that handles requests via remoting
from clients and executes transactions against a third-party server via TCP.
the remoting site works like a champ. my problem is executing the
transactions against the remote server and returning the response to the
remoting client. i can open the socket fine and, if i am executing one
transaction at a time, everything works great. it's when my proxy server...
|
by: Pat B |
last post by:
Hi, I'm writing my own implementation of the Gnutella P2P protocol
using C#. I have implemented it using BeginReceive and EndReceive
calls so as not to block when waiting for data from the supernode.
Everything I have written works fine sending and receiving
uncompressed data. But now I want to implement compression using the
deflate algorithm as the Gnutella protocol accepts:
Accept-Encoding: deflate
Content-Encoding: deflate
in the...
|
by: ahlongxp |
last post by:
socket.makefile() may lose data when "connection reset by peer".
and socket.recv() will never lose the data.
change the "1" to "0" in the client code to see the difference.
confirmed on both windows and linux.
so I guess there is a problem with makefile().
# Echo server program
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |