#!/usr/bin/env rexx socket = socksocket('AF_INET', 'SOCK_STREAM', 'IPPROTO_TCP') host.!family = 'AF_INET' host.!addr = '127.0.0.1' host.!port = '50010' /* connect to the server */ if sockconnect(socket, 'host.!') < 0 then do say 'SockConnect failed:' errno exit end say 'type "X" to exit' do forever call charout , 'Send To Server: ' parse pull message if message~upper() = 'X' then leave /* send message to server */ if socksend(socket, message) < 0 then do say 'SockSend failed:' errno leave end /* get message from server */ ret = sockrecv(socket, 'data', 1024) if ret < 1 then do if ret < 0 then say 'SockRecv failed:' errno else say 'Socket closed:' errno leave end say 'Server responded:' data end /* close the socket connection */ if sockclose(socket) < 0 then say 'SockClose failed:' errno Exit /* Rexx */ ::requires 'rxsock' LIBRARY