*
* Sample Client application
*

setwin( 5, 5, 10, 35 )
wintitle( 'Client Task' )
on close stopit
on click clickfun

for i = 1 to 15
    server_id = name_locate( 'OI_ADMIN' )
    if server_id < 0
        inkey( .1 )
	tone(1000)
    else
        exit
    endif
next i

if server_id < 0
    ? 'Cannot connect to Server task'
    inkey(2)
    quit
endif

@0,0 say 'Client messaging with OI_ADMIN' 
@2,0 say 'Click this window to'
@3,7 say 'terminate process'
clicked = .f.
inbuff=space(20)
max=500
for i = 1 to max 
   send( server_id, str(i), len(str(i)), inbuff, 10 )
   @ 4.5,0 say alltrim(str(i)) + ' messages sent of  ' +  alltrim(str(max))
   if inkey( -1 ) <> 0 .or. clicked
      i = max
   endif
next
stopit()

Function stopit
    para fld, lvl, key, row, cocl
    ? 'Window closed, process terminating.'
    send( server_id, 'q', 1, inbuff, 10 )
    quit
return 

Function clickfun
    clicked = .t.
return 
* --- end ---
