Sockets

Sockets

Postby Jeff Barnes » Thu Apr 21, 2011 11:37 pm

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
Jeff Barnes
 
Posts: 883
Joined: Sun Oct 09, 2005 1:05 pm
Location: Ontario, Canada

Re: Sockets

Postby Antonio Linares » Thu May 05, 2011 7:25 am

Jeff,

Have you created a window previously ?
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 35262
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Sockets

Postby Jeff Barnes » Sat May 07, 2011 12:22 pm

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  Expand view

#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
Jeff Barnes
 
Posts: 883
Joined: Sun Oct 09, 2005 1:05 pm
Location: Ontario, Canada

Re: Sockets

Postby Antonio Linares » Sat May 07, 2011 6:22 pm

Jeff,

What Windows Mobile version are you using ?

Are you running on Windows CE ?
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 35262
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Sockets

Postby Jeff Barnes » Mon May 09, 2011 4:13 pm

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
Jeff Barnes
 
Posts: 883
Joined: Sun Oct 09, 2005 1:05 pm
Location: Ontario, Canada

Re: Sockets

Postby Carles » Fri Jun 10, 2011 6:35 am

Jeff,

No sera esta linea ?
oSocket:bRead = { | oSocket | oSocket:GetData }


Q te faltan los parentesis de funcion ?

Code: Select all  Expand view
     oSocket:bRead    = { | oSocket | oSocket:GetData()  }
Salutacions, saludos, regards

"...programar es facil, hacer programas es dificil..."

http://www.itarraco.com

Siau.
C.
User avatar
Carles
 
Posts: 763
Joined: Fri Feb 10, 2006 2:34 pm
Location: Barcelona

Re: Sockets

Postby Carles » Fri Jun 10, 2011 6:37 am

Jeff

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

Can u try ?

Code: Select all  Expand view
     oSocket:bRead    = { | oSocket | oSocket:GetData()  }
Salutacions, saludos, regards

"...programar es facil, hacer programas es dificil..."

http://www.itarraco.com

Siau.
C.
User avatar
Carles
 
Posts: 763
Joined: Fri Feb 10, 2006 2:34 pm
Location: Barcelona

Re: Sockets

Postby Jeff Barnes » Fri Jun 10, 2011 12:19 pm

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  Expand view

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
Jeff Barnes
 
Posts: 883
Joined: Sun Oct 09, 2005 1:05 pm
Location: Ontario, Canada

Re: Sockets

Postby Daniel Garcia-Gil » Fri Jun 10, 2011 12:48 pm

Hello Jeff


try use a port number more big... ie. 5000
User avatar
Daniel Garcia-Gil
 
Posts: 2365
Joined: Wed Nov 02, 2005 11:46 pm
Location: Isla de Margarita

Re: Sockets

Postby Eugeniusz Owsiak » Wed Jun 29, 2011 8:38 am

Hi Jeff
Code: Select all  Expand view

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
User avatar
Eugeniusz Owsiak
 
Posts: 60
Joined: Fri Oct 07, 2005 5:38 am
Location: Poland

Re: Sockets

Postby stevebrown » Fri Oct 07, 2011 4:57 pm

I am wondering in generaly how WM will be supported as the WP7 Mango just rolled out.
stevebrown
 
Posts: 4
Joined: Fri Oct 07, 2011 1:05 am

Re: Sockets

Postby Antonio Linares » Fri Oct 07, 2011 5:17 pm

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-Appx-Package-from-scratch-you-must-first-e280a6.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
User avatar
Antonio Linares
Site Admin
 
Posts: 35262
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain


Return to FiveWin for Pocket PC

Who is online

Users browsing this forum: No registered users and 1 guest