Page 1 of 1

REXX network client

PostPosted: Wed Mar 06, 2013 3:11 pm
by David85
Hi
I wrote server in Java and client in REXX when i use a REXX Socket ('Send') function server receive message and print, but when REXX next use a Socket ('Read') function the server and client suspended.
The REXX client code:
/*rexx*/
prefix = 'Klient> ';                                                   
port_no = 5000;                                                         
servIP = '192.168.0.1;                                             
                                                                       
call set_tcpip;                                                         
say "Socket: " cl_socket;                                               
                                                                       
  say prefix 'Idetyfikuje serwer';                                     
  s_rc = Socket('Getpeername', cl_socket);                             
  if  word(s_rc, 1) <> 0  then call blad 'Getpername()' s_rc;           
  serv_IPG = word(s_rc, 4);                                             
  say prefix "Polaczony z: " serv_IPG;                                 
                                                                       
/**/                                                                   
say "Napisz cos do serwera: ";                                         
pull z_konsoli;                                                         
  if z_konsoli <> "end" then do                                         
    call wyslij z_konsoli;                                             
                                                                       
    do forever                                                         
    przych = "";                                                       
    s_rc = Socket('Read',cl_socket,10000);                             
    if  word(s_rc, 1) <> 0  then call blad Read() s_rc                 
    przych = przych || word(s_rc, 3)                                   
    Say "Odebralem: " przych;                                           
    end                                                                 
                                                                       
                                                             
  end                                                                   
  else do                                                               
    rc = Socket('Close', cl_socket);                                   
  end                                                                   
                                                                       
rc = Socket('Close', cl_socket);                                       
                                                                       
exit;                                                                   
/*fun*/                                                                 
/*inicjalizacja sodowiska sieciowego*/                                 
set_tcpip:                                                             
                                                                       
s_rc= Socket('Initialize', 'CLIENT');                                   
if  word(s_rc, 1) <> 0 then do                                         
  say prefix 'nie moge zainicjowac socket-u';                           
  say prefix 'rc: ' word(s_rc, 1) word(s_rc,2);                         
  exit(8);                                                             
end                                                                     
                                                                       
s_rc = Socket('Socket','AF_INET');                                     
if  word(s_rc, 1) <> 0  then call blad 'Socket()' s_rc;                 
cl_socket = word(s_rc, 2);                                             
                                                                       
                                                                       
s_rc = Socket('Setsockopt', cl_socket, 'SOL_SOCKET', 'SO_ASCII', 'ON');
if (word(s_rc, 1 ) <> 0) then call blad 'Setsockopt()' s_rc;           
                                                                       
s_rc = Socket('Setsockopt', cl_socket, 'SOL_SOCKET','SO_REUSEADDR','ON')
if (word(s_rc, 1 ) <> 0) then call blad 'Setsockopt()' s_rc;           
                                                                       
s_rc = Socket('Bind', cl_socket, 'AF_INET' port_no);                   
if (word(s_rc, 1 ) <> 0) then call blad 'Bind()' s_rc;                 
                                                                       
serv = "AF_INET" port_no servIP;                                       
say "serv: " serv;                                                     
s_rc = Socket('CONNECT',cl_socket,serv);                               
if (word(s_rc, 1 ) <> 0) then call blad 'CONNECT()' s_rc;               
                                                                       
return cl_socket                                                       
                                                                       
wyslij:                                                                 
  arg komunikat;                                                       
                                                                       
    l = length(komunikat);                                             
    rc = Socket('Write', cl_socket, komunikat, l);                     
return                                                                 
                                                                       
                                                                       
                                                                       
blad: procedure                                                         
                                                                       
 arg msg rc_w;                                                         
 say prefix 'Blad w funkcji: ' msg;                                     
 say prefix 'rc: ' word(rc_w, 1);                                       
 say prefix 'rc: ' word(rc_w, 2);                                       
                                                                       
 rc = Socket('Close', cl_socket);                                       
                                                                       
 rc = Socket('Terminate', 'CLIENT');                                   
                                                                       
 exit(8)                                                               
                                                                       

Re: REXX network client

PostPosted: Wed Mar 06, 2013 3:58 pm
by enrico-sorichetti
did You check
TCPIP.AEZASMP1(RSSERVER)

and the counterpart
TCPIP.AEZASMP1(RSCLIENT)