Sockets

Post Reply
User avatar
Jeff Barnes
Posts: 912
Joined: Sun Oct 09, 2005 1:05 pm
Location: Ontario, Canada
Contact:

Sockets

Post 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?
Thanks,
Jeff Barnes

(FWH 12.01, xHarbour 1.2.1, Bcc582)
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: Sockets

Post by Antonio Linares »

Jeff,

Have you created a window previously ?
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Jeff Barnes
Posts: 912
Joined: Sun Oct 09, 2005 1:05 pm
Location: Ontario, Canada
Contact:

Re: Sockets

Post 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
        
 
Thanks,
Jeff Barnes

(FWH 12.01, xHarbour 1.2.1, Bcc582)
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: Sockets

Post by Antonio Linares »

Jeff,

What Windows Mobile version are you using ?

Are you running on Windows CE ?
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Jeff Barnes
Posts: 912
Joined: Sun Oct 09, 2005 1:05 pm
Location: Ontario, Canada
Contact:

Re: Sockets

Post 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)
Thanks,
Jeff Barnes

(FWH 12.01, xHarbour 1.2.1, Bcc582)
User avatar
Carles
Posts: 937
Joined: Fri Feb 10, 2006 2:34 pm
Location: Barcelona
Contact:

Re: Sockets

Post 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()  }
Salutacions, saludos, regards

"...programar es fácil, hacer programas es difícil..."

https://modharbour.app
https://modharbour.app/compass
https://forum.modharbour.app
User avatar
Carles
Posts: 937
Joined: Fri Feb 10, 2006 2:34 pm
Location: Barcelona
Contact:

Re: Sockets

Post by Carles »

Jeff

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

Can u try ?

Code: Select all

      oSocket:bRead    = { | oSocket | oSocket:GetData()  }
Salutacions, saludos, regards

"...programar es fácil, hacer programas es difícil..."

https://modharbour.app
https://modharbour.app/compass
https://forum.modharbour.app
User avatar
Jeff Barnes
Posts: 912
Joined: Sun Oct 09, 2005 1:05 pm
Location: Ontario, Canada
Contact:

Re: Sockets

Post 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
 
Thanks,
Jeff Barnes

(FWH 12.01, xHarbour 1.2.1, Bcc582)
User avatar
Daniel Garcia-Gil
Posts: 2365
Joined: Wed Nov 02, 2005 11:46 pm
Location: Isla de Margarita
Contact:

Re: Sockets

Post by Daniel Garcia-Gil »

Hello Jeff


try use a port number more big... ie. 5000
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
User avatar
Eugeniusz Owsiak
Posts: 60
Joined: Fri Oct 07, 2005 5:38 am
Location: Poland

Re: Sockets

Post 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
stevebrown
Posts: 4
Joined: Fri Oct 07, 2011 1:05 am

Re: Sockets

Post by stevebrown »

I am wondering in generaly how WM will be supported as the WP7 Mango just rolled out.
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: Sockets

Post 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
regards, saludos

Antonio Linares
www.fivetechsoft.com
Post Reply