Socket Programming good practice

Socket Programming good practice

Postby byron.hopp » Wed May 22, 2024 10:15 pm

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,
Thanks,
Byron Hopp
Matrix Computer Services
byron.hopp
 
Posts: 382
Joined: Sun Nov 06, 2005 3:55 pm
Location: Southern California, USA

Re: Socket Programming good practice

Postby Antonio Linares » Thu May 23, 2024 5:01 am

Dear Byron,

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

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

Re: Socket Programming good practice

Postby Silvio.Falconi » Thu May 23, 2024 8:19 am

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?
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7061
Joined: Thu Oct 18, 2012 7:17 pm

Re: Socket Programming good practice

Postby byron.hopp » Thu May 23, 2024 6:11 pm

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
 
Thanks,
Byron Hopp
Matrix Computer Services
byron.hopp
 
Posts: 382
Joined: Sun Nov 06, 2005 3:55 pm
Location: Southern California, USA


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 42 guests