Page 1 of 1

Sockets

Posted: Thu Apr 21, 2011 11:37 pm
by Jeff Barnes
Hi,

I get a GPF when I try and do a:

oSocket = TSocket():New( 2000 )


I am working with the sockcli.prg program from the \FWPPC\Samples folder.


What can be causing this error?

Re: Sockets

Posted: Thu May 05, 2011 7:25 am
by Antonio Linares
Jeff,

Have you created a window previously ?

Re: Sockets

Posted: Sat May 07, 2011 12:22 pm
by Jeff Barnes
Hi Antonio,

Yes, I have a window. In the window I click a button to activate the connection.

Here is the test code:

Code: Select all

#include "Fwce.ch"

STATIC oWnd, oSocket, cTitle:="Socket Test"
STATIC cSat, cHR, oTmr

Function Main()
    LOCAL oBtn
    DEFINE WINDOW oWnd TITLE cTitle
        @ 1,1 BUTTON oBtn PROMPT "Connect" SIZE 75,25 ACTION Connect()
    ACTIVATE WINDOW oWnd 
Return Nil

Function Connect()
      oSocket = TSocket():New( 2000 )  //Generates a GPF Here
      oSocket:bRead    = { | oSocket | oSocket:GetData  }
      oSocket:bConnect = { || oWnd:SetText( "Connected!" ) }
      oSocket:bClose   = { || MsgInfo( "Server has closed!" ) }
      oSocket:Connect( "127.0.0.1" ) 

      DEFINE TIMER oTmr INTERVAL 1000 of oWnd ACTION GetOxData()
      ACTIVATE TIMER oTmr
return nil

Function GetOxData()
    cSat := PADL( ALLTRIM(STR( ABS(HB_RandomInt( 85, 100 ) ) ) ),3," ")
    cHR  := PADL( ALLTRIM(STR( ABS(HB_RandomInt( 75, 150 )  ) ) ),3, " ")
    SendOx( cSat, cHR )
Return Nil

Function SendOx(cSat, cHR )
    oSocket:SendData( "MSG "+cSat+" "+cHR) 
Return Nil
        
 

Re: Sockets

Posted: Sat May 07, 2011 6:22 pm
by Antonio Linares
Jeff,

What Windows Mobile version are you using ?

Are you running on Windows CE ?

Re: Sockets

Posted: Mon May 09, 2011 4:13 pm
by Jeff Barnes
From the "About Screen" on my mobile device:

Windows Mobile 6.5 Professional
CE OS 5.2.23090 (Build 23090.5.3.0)

Re: Sockets

Posted: Fri Jun 10, 2011 6:35 am
by Carles
Jeff,

No sera esta linea ?
oSocket:bRead = { | oSocket | oSocket:GetData }
Q te faltan los parentesis de funcion ?

Code: Select all

      oSocket:bRead    = { | oSocket | oSocket:GetData()  }

Re: Sockets

Posted: Fri Jun 10, 2011 6:37 am
by Carles
Jeff

Sorry, i know... in english :-)

Can u try ?

Code: Select all

      oSocket:bRead    = { | oSocket | oSocket:GetData()  }

Re: Sockets

Posted: Fri Jun 10, 2011 12:19 pm
by Jeff Barnes
Hi Carles,

I do have the line of code you mention but I get the GPF before I get that far.
This crashes the program: oSocket = TSocket():New( 2000 )

Code: Select all

Function Connect()

      oSocket = TSocket():New( 2000 )  //Generates a GPF Here

      oSocket:bRead    = { | oSocket | oSocket:GetData  }
      oSocket:bConnect = { || oWnd:SetText( "Connected!" ) }
      oSocket:bClose   = { || MsgInfo( "Server has closed!" ) }
      oSocket:Connect( "127.0.0.1" )

      DEFINE TIMER oTmr INTERVAL 1000 of oWnd ACTION GetOxData()
      ACTIVATE TIMER oTmr
return nil
 

Re: Sockets

Posted: Fri Jun 10, 2011 12:48 pm
by Daniel Garcia-Gil
Hello Jeff


try use a port number more big... ie. 5000

Re: Sockets

Posted: Wed Jun 29, 2011 8:38 am
by Eugeniusz Owsiak
Hi Jeff

Code: Select all

Function Connect()
    memvar oSocket
   oSocket = TSocket():New( 2000 )
   oSocket:bRead    = { | oSocket | OnRead( ) }
   oSocket:bConnect = { | oSocket | OnConnect( ) }
   oSocket:bClose   = { | oSocket | OnClose( ) }
   oSocket:Cargo := ST_COMMAND
   oSocket:Connect( "192.168.1.2",2000 ) // server IP adres
Return nil
******************************
Function OnConnect( )
    memvar lConnect,oWnd
   lConnect := .T.
   oWnd:SetText("Connect")

Return nil
**********************
function OnClose(   )
   memvar oSocket,lConnect
   do case
      case oSocket:Cargo == ST_SENDFILE
           fclose( oSocket:hFile )
   endcase
   lConnect := .F.
   oSocket:End()
return nil

 
This is a piece of my working program on WM 5.0 platform.

Eugeniusz

Re: Sockets

Posted: Fri Oct 07, 2011 4:57 pm
by stevebrown
I am wondering in generaly how WM will be supported as the WP7 Mango just rolled out.

Re: Sockets

Posted: Fri Oct 07, 2011 5:17 pm
by Antonio Linares
Steve,

I guess this is the only way to go if we want to keep using Harbour on Windows Phone and Metro:

http://peterdn.com/post/To-make-a-Metro ... 280a6.aspx

But first of all we need a Harbour built for .NET, something that we could have building Harbour with MS C .NET