



say "CLIENT (ooRexx): program started."
/* create socket and connect to server on port 8888 */
lh=.bsf~bsf.import('java.net.InetAddress') ~getLocalHost -- get InetAddress
socket2server=.bsf~new('java.net.Socket', lh, 5000) -- connect to server
say "CLIENT (ooRexx): connected to server" pp(socket2server~toString)
/* send the server data */
call syssleep 2

Nachricht1="Ich bin der Client!"
say "CLIENT (ooRexx): sending" pp(Nachricht1) "to server..."
socket2server~getOutputStream~write(BsfRawBytes(Nachricht1)) -- turn Rexx string to byte array

call syssleep 2

/* receive data from server */
b=.bsf~bsf.createArray('byte.class', 100) -- create a "byte"-array
received=socket2server~getInputStream~read(b) -- returns number of bytes read
say "CLIENT (ooRexx): data received from server: ["time()" "||BsfRawBytes(b,received)"]"

call syssleep 2

Nachricht2="Danke fuer das Akzeptieren"
say "CLIENT (ooRexx): sending" pp(Nachricht2) "to server..."
socket2server~getOutputStream~write(BsfRawBytes(Nachricht2)) -- turn Rexx string to byte array

call syssleep 2

b=.bsf~bsf.createArray('byte.class', 100) -- create a "byte"-array
received=socket2server~getInputStream~read(b) -- returns number of bytes read
say "CLIENT (ooRexx): data received from server: ["time()" "||BsfRawBytes(b,received)"]"

call syssleep 2

say "CLIENT (ooRexx): program ended."
::requires BSF.CLS