Page 1 of 1

TSocket.prg - Possible bug ?

PostPosted: Thu Sep 24, 2009 3:24 pm
by Davide
I use TwebClie.prg to download a file from a remote server:
Code: Select all  Expand view
 oConn:=TWebClient():New()
  oConn:oSocket:lDebug  :=.t.
  oConn:oSocket:cLogFile:=cLog
  oConn:bOnConnect    := { | oS | oS:GetPage(cPage) }
  oConn:bOnRead       := { | cD, oS | cBuffer+=cD }
  oConn:oSocket:bClose:= { | oS | ManageFile(cFile) }  
  oConn:Connect( cSite )

If cSite is down I've noticed that the log file growns very fast, reaching hundreds of Mb in a few minutes, full of lines as follows:
Code: Select all  Expand view
09/24/2009 15:02:56: Sent-1  Len:    112 Buffer Len: 0   Error:  10057   

I've tracked down the problem in tSocket.prg, method SendData():
Code: Select all  Expand view
      if nSent != -1
         cData = SubStr( cData, nSent + 1 )
         nLen  = Len( cData )
      else
         if WSAGetLastError() != WSAEWOULDBLOCK
           // exit  
         endif
      endif
      SysRefresh()

The Exit was not commented in previous FWH versions (I've checked 7.09), and uncommenting it the problem get solved.
Was it a mistake, and my solution is ok, or is there a reason for commenting that line ?

Thanks,
Davide
FWH 9.05 - xH 1.2.1

Re: TSocket.prg - Possible bug ?

PostPosted: Thu Sep 24, 2009 7:27 pm
by Daniel Garcia-Gil
Hello Davide...

is the package received totally ??

does check the integrity of received package

Re: TSocket.prg - Possible bug ?

PostPosted: Thu Sep 24, 2009 9:41 pm
by Davide
Daniel,

thank you for your reply.

If the server is up and running, the package is received ok with or without that "exit" commented. No problem here.

If the server is down, that commented "exit" makes the log file growing forever because the loop in SendData() never ends.
Restoring that line (as it was on older FWH versions) just make oSocket:SendData() finishing in case of errors (that's correct in my opinion because there's nothing to do if the server is down)

Looks like that line was commented by mistake (otherwise why "if WSAGetLastError() != WSAEWOULDBLOCK" and "endif" haven't been commented too ?) but I'd like a confirmation about the opportunity (or not) to restore it.

Hi,
Davide

Re: TSocket.prg - Possible bug ?

PostPosted: Fri Sep 25, 2009 12:32 am
by jllinas
Hi to all,

I read carefully this msgs. This is just to report I developed a system to receive data from a radio receiver (using COM ports), and once receive an string of data, the "receiver system" make a replication to another computer, connected to internet. For this replication a socket routines has been developed using FWH tSocket class and everything goes find for a few hours, but after that the system "hang" without explanation.

I have more than a month looking or this error, but now I can read your experience, I noticed I am using oSocket:SendData() too !

Antonio can make comment on this.... no?

Regards,