FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour TSocket.prg - Possible bug ?
Posts: 190
Joined: Tue Mar 14, 2006 01:59 AM
TSocket.prg - Possible bug ?
Posted: Thu Sep 24, 2009 03:24 PM
I use TwebClie.prg to download a file from a remote server:
Code (fw): Select all Collapse
  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 (fw): Select all Collapse
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 (fw): Select all Collapse
       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
Posts: 2365
Joined: Wed Nov 02, 2005 11:46 PM
Re: TSocket.prg - Possible bug ?
Posted: Thu Sep 24, 2009 07:27 PM

Hello Davide...

is the package received totally ??

does check the integrity of received package

Posts: 190
Joined: Tue Mar 14, 2006 01:59 AM
Re: TSocket.prg - Possible bug ?
Posted: Thu Sep 24, 2009 09:41 PM

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

Posts: 189
Joined: Fri Oct 14, 2005 12:33 AM
Re: TSocket.prg - Possible bug ?
Posted: Fri Sep 25, 2009 12:32 AM

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

Continue the discussion