Announcement

Collapse
No announcement yet.

Data Interrupted

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Data Interrupted

    I wrote an email sending program in PBDLL v6.0, and every once
    in a while in the email received on the other end, the message is
    interrupted and it throws in an exclamation point, a carriage return,
    and another exclamation point. I checked the outgoing message,
    and it doesn't contain those characters when sent, so I figured
    there must be a certain buffer length that has to be sent, so I
    had my program send 1024 byte increments at a time, but the
    problem still occured. I'm just using a standard
    "tcp print htcp&,<string>"
    Anyone ever had this happen?

    Best Regards

    Jim



    ------------------
    Jim Seekamp
    Jim Seekamp

  • #2
    Jim,

    The documentation indicates that a CRLF will be sent if you don't end your
    statement with a semicolon( . (I don't use that area of PB and claim
    no expertise.)

    tcp print htcp&, <string>;

    could that be happening?
    Regards,

    ------------------
    [email protected]
    :) IRC :)

    Comment


    • #3
      Thanks for the response, but no; I'm sending all the data at
      one time (up to 32,000 bytes string) with no carriage returns.

      Best Regards

      Jim



      ------------------
      Jim Seekamp
      Jim Seekamp

      Comment


      • #4
        Now that is bizarre.

        In TCP there is sometimes space that is not used, since it's a byte oriented protocol...

        This space is padded, but CRC checked by the TCP stack, so I would not THINK it would be the stack doing this, unless you are using some inferior stack like Novell or something..(*Grin*)...

        Oh shame, the slamming will begin I'm sure.

        Seriously, I'd put a sniffer on the wire, if you have one, if not send me the code and I can sniff the wire and see if it's on the outgoing side, if it's not in the sniffer, then the issuei s occuring on the receiving end.

        This is how I do all my code writing, very efficient when I can see what's on the wire.

        By the way, assuming it's eithernet you get 1500 bytes (approx, forgot the exact amount), so 1024 is a good buffer.
        Anything over that and it gets split between packets, but it MAY also get fragmented between packets as is, depending how many hops your app is running from the server....


        Scott




        ------------------
        Scott
        mailto:[email protected][email protected]</A>
        Scott Turchin
        MCSE, MCP+I
        http://www.tngbbs.com
        ----------------------
        True Karate-do is this: that in daily life, one's mind and body be trained and developed in a spirit of humility; and that in critical times, one be devoted utterly to the cause of justice. -Gichin Funakoshi

        Comment


        • #5
          Thanks Scott; I don't have a sniffer though.
          Here is a peared-down version of the function:

          Best Regards

          Jim
          Code:
          function smtpsendmail() as long
          
               smtphost$=bsmtp$  ''smtp server
          
               if smtphost$="" then
                 txt$="No SMTP Host Entered - No Emails Will Be Sent"
                 showtextmessage txt$  ''showtextmessage is like msgbox
                 exit function
               end if
          
               ff&=freefile
               open "from.tmp" for binary as #ff& base=0
               get$ #ff&,lof(ff&),b$
               close #ff&
          
               fullemailfrom$=b$
          
               stt&=instr(b$,"<")
               fin&=instr(b$,">")
          
               if stt&>0 and fin&>0 then
                 lngth&=(fin&-stt&)+1
                 emailfrom$=mid$(b$,stt&,lngth&)
               elseif instr(b$,"@") then
                 emailfrom$="<"+b$+">"
               else
                 emailfrom$=""
               end if
          
               if emailfrom$="" or fullemailfrom$="" then
                 showtextmessage "No 'From' Address Specified"
                 exit function
               end if
          
               if dir$("from.tmp")<>"" then kill "from.tmp"
          
               ff&=freefile
               open "subject.tmp" for binary as #ff& base=0
               get$ #ff&,lof(ff&),subject$
               close #ff&
          
               if dir$("subject.tmp")<>"" then kill "subject.tmp"
          
               ''get addresses to send to
          
               if dir$("address.tmp")="" then
                 showtextmessage "No Addresses Specified"
                 exit function
               end if
          
               ''get all addresses to send to
          
               dim dta$(1:1)
          
               ff&=freefile
               open "address.tmp" for input as #ff&
          
               epeople&=0
          
               while not eof(ff&)
                 line input #ff&,ip$
                 b$=trim$(ip$)
          
                 if b$<>"" then
                   stt&=instr(b$,"<")
                   fin&=instr(b$,">")
          
                   if stt&>0 and fin&>0 then
                     lngth&=(fin&-stt&)+1
                     emailto$=mid$(b$,stt&,lngth&)
                   elseif instr(b$,"@") then
                     emailto$="<"+b$+">"
                   else
                     emailto$=""
                   end if
          
                   if emailto$<>"" then
                     incr epeople&
                     redim preserve dta$(1:epeople&)
                     dta$(epeople&)=emailto$
                   end if
          
                 end if
          
               wend
          
               close #ff&
          
               if dir$("address.tmp")<>"" then kill "address.tmp"
          
               ''get message
          
               ff&=freefile
               open "message.tmp" for binary as #ff& base=0
               get$ #ff&,lof(ff&),emessage$
               close #ff&
          
               if dir$("message.tmp")<>"" then kill "message.tmp"
          
               ''create progress bar dialog
               createprogressbar hmess&,hed&,hprogress&
               settext hmess&,"Sending Email(s)"
               settext hed&,"Preparing To Send..."
          
               htcp&=freefile
               tcp open "smtp" at smtphost$ as htcp&
          
               e&=smtpgetline(htcp&,b$)
          
               if e&<>220 then
                 destroywindow hmess&
                 showtextmessage "Error Opening SMTP Host ("+trim$(str$(e&))+")"
                 close htcp&
                 exit function
               end if
          
               ''meet & greet the smtp host
               tcp print htcp&,"HELO "+smtphost$
               e&=smtpgetline(htcp&,b$)
          
               if e&<>250 then
                 destroywindow hmess&
                 showtextmessage "Error Greeting SMTP Host ("+trim$(str$(e&))+")"
                 close htcp&
                 exit function
               end if
          
               oldprogbar&=0
          
               on error goto smtperror
          
               for z&=1 to epeople&
                 emailto$=dta$(z&)
          
                 progbar&=(z&*100)/epeople&
          
                 if progbar&<>oldprogbar& then
                   oldprogbar&=progbar&
                   settext hed&,"Sending: "+emailto$
                   setpositionprogressbar hprogress&,progbar&
                 end if
          
                 do
                   tcp print htcp&,"MAIL FROM:"+emailfrom$
                   e&=smtpgetline(htcp&,b$)
          
                   if e&<>250 then
                     showtextmessage "Sender Address Error "+trim$(str$(e&))+" ("+emailfrom$+")"
                     exit loop
                   end if
          
                   tcp print htcp&,"RCPT TO:"+emailto$
                   e&=smtpgetline(htcp&,b$)
          
                   if e&<>250 then
                     showtextmessage "Recipient Address Error "+trim$(str$(e&))+" ("+emailto$+")"
                     exit loop
                   end if
          
                   tcp print htcp&,"DATA"
                   e&=smtpgetline(htcp&,b$)
          
                   if e&<>354 then
                     showtextmessage "Data Error "+trim$(str$(e&))+" ("+emailto$+")"
                     exit loop
                   end if
          
                   ''message header
                   tcp print htcp&,"From: "+fullemailfrom$
                   tcp print htcp&,"Subject: "+subject$
          
                   ''this is the 1024 buffer code - I took it back out
                   'lmg&=len(emessage$)
                   'xstt&=1
                   'if lmg&>1024 then xfin&=1024 else xfin&=lmg&
                   '
                   'do until xstt&>lmg&
                   '  lngth&=(xfin&-xstt&)+1
                   '  ip$=mid$(emessage$,xstt&,lngth&)
                   '  lip$=left$(ip$,1)
                   '  if lip$="." then ip$="."+ip$
                   '  tcp print htcp&,ip$;
                   '  xstt&=xfin&+1
                   '  xfin&=xfin&+1024
                   '  if xfin&>lmg& then xfin&=lmg&
                   'loop
          
                   'tcp print htcp&," "
          
                   ''all bytes at once
                   ip$=left$(emessage$,1)
                   if ip$="." then emessage$="."+emessage$
                   tcp print htcp&,emessage$
          
                   ''end of message
                   tcp print htcp&,"."
                   e&=smtpgetline(htcp&,b$)
          
                   if e&<>250 then
                     showtextmessage "Sending Email Message Error "+trim$(str$(e&))+" ("+emailto$+")"
                   end if
          
                   exit loop
                 loop
          
               next z&
          
               setpositionprogressbar hprogress&,100
          
               tcp print htcp&,"QUIT"
               e&=smtpgetline(htcp&,b$)
          
               destroywindow hmess&  ''destroy progress dialog
          
               if e&<>221 then
                 showtextmessage "Quit Error ("+trim$(str$(e&))+")"
               else
                 e&=0  ''successful
                 showtextmessage "Your emails were successfully sent"
               end if
          
               close htcp&
          
               redim dta$(1:1)
          
               function=e&
               exit function
          
          smtperror:
          
               e&=err
          
               close htcp&
          
               destroywindow hmess&
          
               showtextmessage "Undefined Error ("+trim$(str$(e&))+")"
          
               redim dta$(1:1)
          
               function=e&
               exit function
          
          end function
          
          function smtpgetline(byval htcp&,b$) as long
          
               if tcpgetline(htcp&,b$) then
                 exit function
               else
                 function=val(left$(b$,3))
                 b$=mid$(b$,5)
               end if
          
          end function
          ------------------
          Jim Seekamp
          Jim Seekamp

          Comment

          Working...
          X