Page 1 of 1

Socket Programming good practice

PostPosted: Wed May 22, 2024 10:15 pm
by byron.hopp
I just started building an app to interact with Sony Pro TV's via ethernet. I have been able to initialize the tv and bring them up but I have to use syswait after all calls to the socket. Upon connecting to the TV it returns 4 messages all about 22 bytes each. Is there a way to determine when the reading of data is complete so I know when to senddata to the TV. After each senddata the TV responds with 1 to n messages, again I would like to know when it is finished so I know when to ask the next question. For now I wait 1 second and it seems to work. Reminds me of the days with RS232.

Thanks,

Re: Socket Programming good practice

PostPosted: Thu May 23, 2024 5:01 am
by Antonio Linares
Dear Byron,

Here you have a good example of using Harbour's sockets:
https://github.com/FiveTechSoft/wsserver/blob/master/wsserver.prg

Re: Socket Programming good practice

PostPosted: Thu May 23, 2024 8:19 am
by Silvio.Falconi
Antonio Linares wrote:Dear Byron,

Here you have a good example of using Harbour's sockets:
https://github.com/FiveTechSoft/wsserver/blob/master/wsserver.prg




I don't know if it's the same thing but I would have to synchronize a warehouse that is in my school and another that is located in another location and I haven't understood how to do it, can we have a practical example to try with?

Re: Socket Programming good practice

PostPosted: Thu May 23, 2024 6:11 pm
by byron.hopp
I am using tsocket from Fivewin, is that not recommended any more? This works, it just uses waits which I always frown upon.

Code: Select all  Expand view

function InitializeSonyPro( nListenPort,cBraviaIp )
    Local oSocket  := nil

    oSocket = TSocket():New( nListenPort )
        oSocket:Connect( cBraviaIp )
    SysWait( 1 )                 // wish I could get rid of these...
    // GetIpCommandString returns the sony command it text.
    oSocket:SendData( GetIpCommandString("setPowerStatusOn" ) )
    SysWait( 1 )
    oSocket:SendData( GetIpCommandString("setInputHDMI1"    ) )
    SysWait( 1 )
    oSocket:Close()

return nil