TSocket.prg - Possible bug ?

Post Reply
Davide
Posts: 190
Joined: Tue Mar 14, 2006 1:59 am
Location: Italy

TSocket.prg - Possible bug ?

Post by Davide »

I use TwebClie.prg to download a file from a remote server:

Code: Select all

  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

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

       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
User avatar
Daniel Garcia-Gil
Posts: 2365
Joined: Wed Nov 02, 2005 11:46 pm
Location: Isla de Margarita
Contact:

Re: TSocket.prg - Possible bug ?

Post by Daniel Garcia-Gil »

Hello Davide...

is the package received totally ??

does check the integrity of received package
our best documentation is the source code
Isla de Margarita Venezuela.
danielgarciagil@gmail.com
http://tdolphin.blogspot.com/
https://www.dropbox.com/referrals/NTI5N ... rc=global9
Davide
Posts: 190
Joined: Tue Mar 14, 2006 1:59 am
Location: Italy

Re: TSocket.prg - Possible bug ?

Post 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
User avatar
jllinas
Posts: 189
Joined: Fri Oct 14, 2005 12:33 am
Location: Santo Domingo, Dominican Republic
Contact:

Re: TSocket.prg - Possible bug ?

Post 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,
Julio Llinás
Visita mi Blog en http://mangucybernetico.blogspot.com/
xHarbour 1.1.0 + FWH810 + Borland 5.5.1
Post Reply