TSocket.prg - Possible bug ?

TSocket.prg - Possible bug ?

Postby Davide » Thu Sep 24, 2009 3:24 pm

I use TwebClie.prg to download a file from a remote server:
Code: Select all  Expand view  RUN
 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  RUN
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  RUN
      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
Davide
 
Posts: 190
Joined: Tue Mar 14, 2006 1:59 am
Location: Italy

Re: TSocket.prg - Possible bug ?

Postby Daniel Garcia-Gil » Thu Sep 24, 2009 7:27 pm

Hello Davide...

is the package received totally ??

does check the integrity of received package
User avatar
Daniel Garcia-Gil
 
Posts: 2365
Joined: Wed Nov 02, 2005 11:46 pm
Location: Isla de Margarita

Re: TSocket.prg - Possible bug ?

Postby Davide » Thu Sep 24, 2009 9: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
Davide
 
Posts: 190
Joined: Tue Mar 14, 2006 1:59 am
Location: Italy

Re: TSocket.prg - Possible bug ?

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


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 18 guests