Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Winsock Component Problem(Events not firing)
Message
General information
Forum:
Visual FoxPro
Category:
ActiveX controls in VFP
Miscellaneous
Thread ID:
00962686
Message ID:
00962761
Views:
10
Hi Franco,

This is a core my jabber client:
DEFINE CLASS _jabberclientWS2 AS OLECONTROL
   Name="_jabberclientWS2"

   OLEClass="Catalyst.SocketCtrl.1"

   PROCEDURE Init()
      This.Object.AddressFamily = 2
      This.Object.Protocol = 0
      This.Object.SocketType = 1
      This.Object.Binary = 1
      This.Object.Blocking = .F.
      This.Object.BufferSize = 2048 && 8192
   ENDPROC

   PROCEDURE VFPConnect(m.lcServer,m.liPort)
      IF LEN(CHRTRAN(m.lcServer,".0123456789",""))>0
         This.HostName=m.lcServer
         This.HostAddress=""
      ELSE
         This.HostName=""
         This.HostAddress=m.lcServer
      ENDIF
      This.RemotePort= LTRIM(STR(m.liPort,11))
      =This.Object.Startup() && Call socket method
      =This.Object.Connect() && Call socket method
      =This.Connected() && Call custom method
   ENDPROC


   PROCEDURE VFPDisconnect()
      This.Object.Cleanup() && Call socket method
   ENDPROC

   PROCEDURE SendData(lcData)
      *@lcData - Data na odeslání
      LOCAL lcBuffer,lii,loobj
      loobj=m.This.Object
      lii=0
      debugout "writing _"+;
               IIF(m.loobj.IsBlocked,"Block ","NoBlock ")+;
               IIF(m.loobj.IsWritable,"Write ","Read ")

      IF m.loobj.IsWritable
         lii=m.loobj.Write(@m.lcData,LEN(m.lcData)) && Call socket method
         debugout "writing "+str(m.lii,11)
      ELSE
*         =m.loobj.Flush() && Call socket method
         lii=-2
      ENDIF
      RETURN m.lii
   ENDPROC

   PROCEDURE Connected() && Custom method
      debugout "Connected to server..."
   ENDPROC


   PROCEDURE Read(datalength, isurgent) && Event
      *** Události ovládacích prvkù ActiveX ***
      LOCAL lcData,lcPom,loObj
      lcData=""
      loObj=This.Object

      lcPom=SPACE(datalength)
      loObj.Read(@lcPom,datalength)
      lcData=lcPom

      DO WHILE loObj.RecvNext>0
         lcPom=SPACE(loObj.RecvNext)
         loObj.Read(@lcPom,loObj.RecvNext)
         lcData=lcData+lcPom
      ENDDO
      This.DataArrival(@lcData)
*      debugout "read data: "+lcData
   ENDPROC

   PROCEDURE DataArrival(lcData)
      IF EMPTY(m.lcData)
         RETURN
      ENDIF

   ENDPROC

   PROCEDURE Write() && Event
      debugout "SendComplete"
   ENDPROC

   PROCEDURE Error(nError, cMethod, nLine)
      * nError
      * cMethod
      * nLine
      debugout "WS Error: "+LTRIM(STR(m.nError,11))+" "+m.cMethod+" "+LTRIM(STR(m.nLine,11))
   ENDPROC

   PROCEDURE GetState()
      RETURN IIF(This.Object.IsClosed, sckClosed,IIF(This.Object.Connected, sckConnected,sckError))
   ENDPROC

ENDDEFINE
MartinJ

>Does anyone has any sample code using the component SocketWrench SP4(Catalyst). I am trying it out but there are certain events which are not firing.
>
>Where can i find some good winsock components with VFP samples?
"Navision is evil that needs to be erazed... to the ground"

Jabber: gorila@dione.zcu.cz
Jabber? Jabbim
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform