Salesforce

How to set socket options using OpenEdge HttpClient?

« Go Back

Information

 
TitleHow to set socket options using OpenEdge HttpClient?
URL NameHow-to-set-socket-options-using-OpenEdge-HttpClient
Article Number000122627
EnvironmentProduct: OpenEdge
Version: 11.5.1,11.6,11.7,12.x
OS: All Supported Platforms
Other: HttpClient
Question/Problem Description

Introduction

The below example shows how to set various options on the ABL client socket object used by the HTTP Client.

Usage

The table below shows the mapping from OpenEdge.Net.ServerConnection.ClientSocket properties to ABL socket option name passed into the SET-SOCKET-OPTION() method.

Option nameProperty nameHttp Client usageDescription (from ABL Help)
TCP-NODELAYNoDelayLOGICALAn enable indicator, which is either TRUE or FALSE.
SO-KEEPALIVEKeepAliveLOGICALSets the TCP socket option SO_KEEPALIVE. Set arguments to TRUE to turn this option on or to FALSE to turn it off.
SO-REUSEADDRReuseAddressLOGICALSets the TCP socket option SO_REUSEADDR. Set arguments to TRUE to turn this option on or to FALSE to turn it off.
SO-RCVBUFReceiveBufferSizeINTEGERSets the TCP socket option SO_RCVBUF or SO_SNDBUF. Set arguments to the desired size of the buffer.
SO-SNDBUFSendBufferSizeINTEGERSets the TCP socket option SO_RCVBUF or SO_SNDBUF. Set arguments to the desired size of the buffer. Note: Depending on your platform, the value you supply might be increased to the platform's minimum buffer size, decreased to the platform's maximum buffer size, or rounded up to the next multiple of the platform's segment size. For more information, see your platform's documentation.
SO-RCVTIMEOReceiveTimeoutINTEGERSets the timeout length—that is, the number of seconds the socket waits to receive data before timing out. Set arguments to the desired timeout value in seconds. If a timeout occurs, READ( ) returns TRUE and the value of BYTES-READ is zero. This is true whether the READ( ) mode is READ-AVAILABLE or READ-EXACT-NUM. For more information on the interaction of READ( ), the READ( ) mode, and SO_RCVTIMEO, see OpenEdge Development: Programming Interfaces.
 
Steps to Reproduce
Clarifying Information
Error Message
Defect Number
Enhancement Number
Cause
Resolution
/*------------------------------------------------------------------------
    File        : set_options.p
    Description : Illustrates setting options on a socket for use with the 
                  http client
    Notes       :
  ----------------------------------------------------------------------*/
BLOCK-LEVEL ON ERROR UNDO, THROW.

USING OpenEdge.Core.LogLevelEnum.
USING OpenEdge.Net.HTTP.ClientBuilder.
USING OpenEdge.Net.HTTP.IHttpClientLibrary.
USING OpenEdge.Net.HTTP.IHttpRequest.
USING OpenEdge.Net.HTTP.IHttpResponse.
USING OpenEdge.Net.HTTP.Lib.ClientLibraryBuilder.
USING OpenEdge.Net.HTTP.RequestBuilder.
USING OpenEdge.Net.ServerConnection.ClientSocket.

/* ********************  Preprocessor Definitions  ******************** */
DEFINE VARIABLE oSocket AS ClientSocket       NO-UNDO.
DEFINE VARIABLE oLib    AS IHttpClientLibrary NO-UNDO.
DEFINE VARIABLE oReq    AS IHttpRequest       NO-UNDO.
DEFINE VARIABLE oResp   AS IHttpResponse      NO-UNDO.

SESSION:DEBUG-ALERT       = TRUE.
SESSION:ERROR-STACK-TRACE = TRUE.

/* ***************************  Main Block  *************************** */
ASSIGN oSocket                = NEW ClientSocket()
       oSocket:ReceiveTimeout = 30
       oLib = ClientLibraryBuilder:Build()
                :Option(GET-CLASS(ClientSocket):TypeName, oSocket)
                :Library
       oReq = RequestBuilder:get('http://httpbin.org/get')
                    :Request.

oResp = ClientBuilder:Build()
              :UsingLibrary(oLib)
              :Client
              :Execute(oReq).
            
MESSAGE oResp:StatusCode SKIP
        oResp:ContentLength SKIP
        oResp:ContentType SKIP
        oResp:Entity
    VIEW-AS ALERT-BOX.            
            
                            
CATCH oError AS Progress.Lang.Error :
    MESSAGE oError:GetMessage(1) SKIP
            oError:CallStack
        VIEW-AS ALERT-BOX.
END CATCH.

 
Workaround
Notes
References to Other Documentation:

Progress Article(s):
 Is there an HTTP client for OpenEdge?
 OpenEdge.Net.pl is missing from PROPATH

​​​​​​​
Keyword Phrase
Last Modified Date11/20/2020 7:01 AM

Powered by