Hi,

I am running my rexx application on z/OS webserver (z/OS USS). The server application is residing on a UNIX server.

I am trying to connect my rexx client application to a SSL enabled server (my server is not SSL enabled).

When I execute my code, I get the following output:
Code:
Socket initialized
EBCDIC to ASCII conversion set.
Socket status is: 0 CLIENT Connected Free 1 Used 1
CONNECTION ESTABLISED
IOCTL failed with info 45 EOPNOTSUPP Operation not supported on socket
SOCKET TERMINATED
I have spent a long time searching and trying some things but to no avail. I would really appreciate your help.

Here is the REXX code:
Code:
/*rexx*/
/*Rexx program to simulate a HTTP GET operation.*/

rc = 0;

fc = SOCKET('Terminate');

Call !HTTP_Write '<html><head><title>REXX HTTP GET.</title></head>';
Call !HTTP_Write '<body>';

fc = SOCKET('Initialize','CLIENT',2);
parse var fc socket_rc .


if socket_rc <> 0 then
Do;
 Call !HTTP_Write 'INITIALIZE failed with return info ' fc '<br />';
 Call http_end;
 Exit 200;
End;

Call !HTTP_Write 'Socket initialized<br />';

fc = SOCKET('SOCKET',2,'SOCK_STREAM','TCP');
parse var fc socket_rc newsocketid .

if socket_rc <> 0 then
Do;
 Call !HTTP_Write 'SOCKET failed with return info ' fc '<br />';
 fc = SOCKET('TERMINATE');
 Call http_end;
 Exit 200;
End;

/* Setup the mainframe TCP/IP to use EBCDIC to ASCII conversion */
fc = SOCKET('Setsockopt',newsocketid,'SOL_SOCKET','SO_ASCII','On');
parse var fc asciirc .

if asciirc <> 0 then
Do;
 Call !HTTP_Write 'EBCDIC to ASCII conversion failed with<br />';
 Call !HTTP_Write 'rc = ' fc '<br />';
 Call SHUTDOWN_LABEL;
 Call http_end;
 Exit 200;
End;

Call !HTTP_Write 'EBCDIC to ASCII conversion set.<br />';

fc = SOCKET('Socketsetstatus','CLIENT');
Call !HTTP_Write 'Socket status is: ' fc '<br />';

CR = D2C(13);
lf = '25'x;
cr = '0d'x;

httpreq="GET" url "HTTP/1.0"||cr||lf ,
"Accept: text/plain, text/html, text/*"||cr||lf||cr||lf;

fc = SOCKET('CONNECT',newsocketid,'AF_INET' 443 XX.XX.X.XX);
parse var fc connect_rc rest

if connect_rc <> 0 then
Do;
 Call !HTTP_Write 'CONNECT failed with return info ' fc '<br />';
 rc = 99;
 Call SHUTDOWN_LABEL;
 Call http_end;
 Exit 200;
End;

Call !HTTP_Write 'CONNECTION ESTABLISED <br />';

fc = SOCKET('IOCTL',newsocketid,'SIOCTTLSCTL','INITCONNECTION');

if ioctlrc <> 0 then
Do;
 Call !HTTP_Write 'IOCTL failed with info ' fc '<br />';
 Call SHUTDOWN_LABEL;
 Call http_end;
 Exit 200;
End;

Call !HTTP_Write 'Sending string: ' httpreq '<br />';

fc = SOCKET('Write',newsocketid,httpreq);
parse var fc send_rc num_sent_bytes

if send_rc <> 0 then
Do;
 Call !HTTP_Write 'WRITE failed with return info ' fc '<br />';
 rc = 99;
 Call SHUTDOWN_LABEL;
 Call http_end;
 Exit 200;
End;

received_string = read_from_socket();


Call !HTTP_Write 'Received string: <br />' received_string '<br />';
Call SHUTDOWN_LABEL;
Call http_end;

Return 200;

/*SHUTDOWN_LABEL
Call this function to close the socket.*/

SHUTDOWN_LABEL:

fc = SOCKET('CLOSE',newsocketid);
parse var fc close_rc rest

if close_rc <> 0 then
Do;
 Call !HTTP_Write 'CLOSE failed with return info ' fc '<br />';
 fc = SOCKET('TERMINATE');
End;

Call !HTTP_Write 'SOCKET TERMINATED <br />';

return;

/*read_from_socket
Call this function to read from socket.*/
read_from_socket:

Response = '';

fc =  Socket('Recv',newsocketid,10000);
parse var fc s_rc s_type s_port s_ip s_results
parse var fc s_rc s_data_len s_data_text

if s_rc <> 0 then
Do;
 Call !HTTP_Write 'Receive failed. fc = ' fc '<br />';
 Call http_end;
 Exit 200;
End;

Response = translate(s_data_text,'   ',x2c('0D1525'));
Response = '<XMP>'||Response||'</XMP>';

Return Response;

/*http_end
Function to end the html tags.*/
http_end:

 Call !HTTP_Write '</body></html>';
Return;

/*!HTTP_Write
Call the HTTP Write service*/

!HTTP_Write:
  Parse arg pout
  ADDRESS LINKMVS 'IMWXWRT pout'
Return;