🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: news.software.nntp
6 messages
6 total messages Started by Yuri Schaeffer Sat, 06 Mar 2004 22:38
homebrew nntp server: outlook behaves strange!
#68461
Author: Yuri Schaeffer
Date: Sat, 06 Mar 2004 22:38
35 lines
2385 bytes
Hi,

I'm currently programming a news server, just for fun and practice, but 
there's a strange problem I ran into. (note that it is far from finished)

Here is a snippit where it is about, the client asks for a specific 
message and the server answers it is ok and sends the message:

C: "ARTICLE 21"
S: "220 21 <21@schaeffer.tk> article retrieved - head and body follow"
S: "Subject: Usenet Etiquette -- Please Read"
S: "From: yuri@schaeffer.tk (Yuri)"
S: "Date: Sat, 06 Mar 2004 13:35:48 GMT"
S: "Message-ID: <21@schaeffer.tk>"
S: "references: <20@schaeffer.tk>"
S: ""
S: "blah"
S: "."

Now, if I run my nntp-server on my local computer (winXP). Outlook 
express 6 as wel mozilla thunderbird 0.5 display the article as they should.
but if I run the nntp-server on my server (Red Hat 8) and connect with 
my clients to it (still running on winXP) something strange happends:

Altough the nntp-server behaves exactly the same, outlook express waits 
forever to recieve the message. it does the request (ARTICLE 21) but 
then waits and waits and eventually times out.
Thunderbird on the otherhand just does what it is supposed to do. So it 
seems my server nor my nntp-server are the problem.

but what is? anyone has just a shadow of a clue?

much appreciated,
Yuri
Re: homebrew nntp server: outlook behaves strange!
#68462
Author: iMeowbot
Date: Sat, 06 Mar 2004 23:05
18 lines
2421 bytes
In article <Zps2c.1903$pN4.1155@amsnews03.chello.com>,
 Yuri Schaeffer <mikrosofty@hotmail.com> wrote:

> Now, if I run my nntp-server on my local computer (winXP). Outlook 
> express 6 as wel mozilla thunderbird 0.5 display the article as they should.
> but if I run the nntp-server on my server (Red Hat 8) and connect with 
> my clients to it (still running on winXP) something strange happends:
> 
> Altough the nntp-server behaves exactly the same, outlook express waits 
> forever to recieve the message. it does the request (ARTICLE 21) but 
> then waits and waits and eventually times out.
> Thunderbird on the otherhand just does what it is supposed to do. So it 
> seems my server nor my nntp-server are the problem.

Are you by any chance going through standard IO and trying to use your 
sockets in text mode?  Don't do that, it may do the right thing under 
Windows but it will produce the wrong results under Unix.  Always open 
your streams as binary and explicity send the line ending as \r\n .
Re: homebrew nntp server: outlook behaves strange!
#68464
Author: Yuri Schaeffer
Date: Sat, 06 Mar 2004 23:38
12 lines
1868 bytes
> Are you by any chance going through standard IO and trying to use your 
> sockets in text mode?  Don't do that, it may do the right thing under 
> Windows but it will produce the wrong results under Unix.  Always open 
> your streams as binary and explicity send the line ending as \r\n .

Ok thanks I'll take a look at it. (I'm not sure wheter the sockets are 
binary, but I'll replace alle the \n with \r\n) This infact might be the 
problem since I did some test a various machines over the network and 
found out it only goes wrong when the server runs on linux. I'll let it 
know.

Yuri
Re: homebrew nntp server: outlook behaves strange!
#68466
Author: Yuri Schaeffer
Date: Sat, 06 Mar 2004 23:53
14 lines
1907 bytes
> Are you by any chance going through standard IO and trying to use your 
> sockets in text mode?  Don't do that, it may do the right thing under 
> Windows but it will produce the wrong results under Unix.  Always open 
> your streams as binary and explicity send the line ending as \r\n .

The line endings where indeed the problem. (I use java btw) I use the 
println method of a PrintWriter, apperently it only uses a \n this is 
fixed now by manually add a \r.

I couln't find anything about opening my Sockets in binary in the API I 
presume it is binary by default. My news-server works fine now.

Thank you very much!
Yuri
Re: homebrew nntp server: outlook behaves strange!
#68468
Author: Yuri Schaeffer
Date: Sun, 07 Mar 2004 08:06
17 lines
1960 bytes
I Think something went wring with my reply, a repost:

 > Are you by any chance going through standard IO and trying to use 
your sockets in text mode?  Don't do that, it may do the right thing 
under Windows but it will produce the wrong results under Unix.  Always 
open your streams as binary and explicity send the line ending as \r\n .


The line endings where indeed the problem. (I use java btw) I use the 
println method of a PrintWriter, apperently it only uses a \n this is 
fixed now by manually add a \r.

I couln't find anything about opening my Sockets in binary in the API I 
presume it is binary by default. My news-server works fine now.

Thank you very much!
Yuri
Re: homebrew nntp server: outlook behaves strange!
#68470
Author: Curt Welch
Date: Sun, 07 Mar 2004 17:13
43 lines
3599 bytes
Yuri Schaeffer <mikrosofty@hotmail.com> wrote:
> I Think something went wring with my reply, a repost:
>
>  > Are you by any chance going through standard IO and trying to use
> your sockets in text mode?  Don't do that, it may do the right thing
> under Windows but it will produce the wrong results under Unix.  Always
> open your streams as binary and explicity send the line ending as \r\n .
>
> The line endings where indeed the problem. (I use java btw) I use the
> println method of a PrintWriter, apperently it only uses a \n this is
> fixed now by manually add a \r.
>
> I couln't find anything about opening my Sockets in binary in the API I
> presume it is binary by default. My news-server works fine now.

When trying to port code between Windows and Unix you have to be very
careful to get this line-ending stuff correct.  It's not always easy
because the various packages you use might be converting LF to CR LF for
you on one platform but not another.

Over the network, you have to send CR LF at the end of the line.  If you
only send LF, then you get the problem you saw.  But if you send CR CR LF,
it might seem to work because articles display correctly, but you are
actually corrupting articles.  You must have the right tools to test with
to make sure you are sending exactly what you should be sending.  Outlook
express and other such newsreaders are a good first test, but it's not the
right tool to really make sure your server is doing what it should.

I don't know Java so I can't give you any advise about that.  But the point
about using a stream in binary mode was the idea that you should try to
turn off any type of automatic conversion from LF to CR LF, or CR ro CR LF
etc.  The C stdio package will do platform specific conversions of LF (unix
end of line), to CR LF, (DOS/Windows end of line), when it is in text mode
(the default).  But if you open the stream in binary mode, it disables
those platform specific conversions.  It's possible that Java has some
platform specific coversions like that as well and you should try and do
the socet IO in a way where the IO package won't try to do any platform
specific text-file conversions for you because the NNTP stream is not
platform specific - it must be the same on all platforms.

-- 
Curt Welch                                            http://CurtWelch.Com/
curt@kcwc.com                          Webmaster for http://NewsReader.Com/
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads