On Sun, 16 Nov 2003, Alvaro Zuniga wrote:

> My question is: is it possible for the NNTP server to block automated 
> scripts? 
> can the NNTP server tell the diference between a telnet session and the 
> script? or is there something wrong with the script I have written that I 
> might have overlooked. I have also tried inserting sleep( 1 ); in various 
> places and even after every statement just in case that the server response 
> was to slow.

Theoretically no, in most cases the server can't tell the difference.  
With php and text-based protocols like SMTP and POP (and NNTP), i've had
better luck using fputs and fgets.  Also, you really need to be waiting
for the server to return status codes.  I think that's what the problem
is, the TCP connection is up but you're done with all the fwrites before
the server is even ready for data.  When you first connect, wait for
status 200.  If you start sending post data before the server is ready,
it'll never make it:

200 news.datasync.com InterNetNews NNRP server INN 2.3.5 ready (posting 
ok).

Use fgets and wait for the ^200.  Something like this:

$connection = fsockopen ('news.cox-internet.com', 119, &$errno, &$errstr, 1);
if (!$connection)
   die();
$res=fgets($connection,256);
if(substr($res,0,3) != "100") {
        echo "Error connecting";
}


Then you can fputs POST.  Then wait for ^340

340 Ok, recommended ID <[EMAIL PROTECTED]>

Then post your article, and wait for ^240 when done

240 Article posted <[EMAIL PROTECTED]>


Just watch your telnet session to get the status codes (what i did).  
They are also well documented in the NNTP RFC's.  If you want to be
thorough, you should expect other status codes as well.  Or if you receive
a status you're not expecting, throw an error condition and echo what the
server said.

ray
-- 
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Ray DeJean                                       http://www.r-a-y.org
Systems Engineer                    Southeastern Louisiana University
IBM Certified Specialist              AIX Administration, AIX Support
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=





Reply via email to