Topic
  • No replies
SystemAdmin
SystemAdmin
403 Posts

Pinned topic TCP Socket to Socket - FIN Message

‏2012-02-06T20:34:01Z |
In TCP/IP Socket programming using COBOL language, could you please let me know how can I send the 'FIN' message to the destination server. Sending a TCP FIN message means "I am finished sending", but Socket close means means "I am finished sending and receiving.
For (e.g.) Application A decides to stop sending data and sends a FIN message to Application B. In Java, I believe it can be accomplished by shutdownOutput(). In COBOL how do we signal the destination system saying 'Iam finished sending' by sending a FIN message.

Any feedback on this topic is appreciated!

Thanks!
Updated on 2012-05-13T13:36:29Z at 2012-05-13T13:36:29Z by SystemAdmin
  • SystemAdmin
    SystemAdmin
    403 Posts

    Re: TCP Socket to Socket - FIN Message

    ‏2012-04-11T22:55:35Z  
    Sorry to take so long in responding...

    If you can tell us what TCP/IP expects, we can tell you how to do it
    in COBOL. COBOL does not have an interface to TCP/IP, but TCP/IP has
    interfaces that it documents. I do not know TCP/IP much, but I know
    COBOL, so if you can tell me what "Sending a TCP FIN message" is,
    I can tell you how to do it in COBOL. I think there are C examples
    in the TCP/IP books, if you post the C, I can tell you how to do the same thing in COBOL.

    Tom
    COBOL is the Language of the Future!
  • infocat
    infocat
    15 Posts

    Re: TCP Socket to Socket - FIN Message

    ‏2012-04-12T00:31:02Z  
    Use the SHUTDOWN function.

    From z/OS V1R12.0 Communications Server IP Sockets Application Programming Interface Guide and Reference:
    "One way to terminate a network connection is to issue the CLOSE call which attempts to complete all outstanding data transmission requests prior to breaking the connection. The SHUTDOWN call can be used to close one-way traffic while completing data transfer in the other direction. The HOW parameter determines the direction of traffic to shutdown.

    When the CLOSE call is used, the SETSOCKOPT OPTVAL LINGER parameter determines the amount of time the system will wait before releasing the connection. For example, with a LINGER value of 30 seconds, system resources (including the IMS™ or CICS® transaction) will remain in the system for up to 30 seconds after the CLOSE call is issued. In high volume, transaction-based systems like CICS and IMS, this can impact performance severely.

    If the SHUTDOWN call is issued when the CLOSE call is received, the connection can be closed immediately, rather than waiting for the 30-second delay."

    I've not used it myself (that I can recall!), but here's some example COBOL code I found on the web (http://ezasoket.googlecode.com/svn-history/r18/trunk/test/src/listen02.cbl):

    
    MOVE 
    'SHUTDOWN' TO EZA-FUNCTION MOVE +0 TO EZA-ERRNO MOVE +0 TO EZA-RETCODE MOVE +2 TO EZA-HOW CALL 
    'EZASOKET' USING EZA-FUNCTION EZA-S-ORIGINAL EZA-HOW EZA-ERRNO EZA-RETCODE END-CALL MOVE EZA-FUNCTION TO CURRENT-FUNCTION MOVE EZA-ERRNO TO CURRENT-ERROR IF EZA-RETCODE IS LESS THAN +0 DISPLAY 
    "SHUTDOWN failed with retcode " EZA-RETCODE 
    " errno " EZA-ERRNO UPON CONSOLE GO TO AB-0001 END-IF
    
  • SystemAdmin
    SystemAdmin
    403 Posts

    Re: TCP Socket to Socket - FIN Message

    ‏2012-05-13T13:36:29Z  
    • infocat
    • ‏2012-04-12T00:31:02Z
    Use the SHUTDOWN function.

    From z/OS V1R12.0 Communications Server IP Sockets Application Programming Interface Guide and Reference:
    "One way to terminate a network connection is to issue the CLOSE call which attempts to complete all outstanding data transmission requests prior to breaking the connection. The SHUTDOWN call can be used to close one-way traffic while completing data transfer in the other direction. The HOW parameter determines the direction of traffic to shutdown.

    When the CLOSE call is used, the SETSOCKOPT OPTVAL LINGER parameter determines the amount of time the system will wait before releasing the connection. For example, with a LINGER value of 30 seconds, system resources (including the IMS™ or CICS® transaction) will remain in the system for up to 30 seconds after the CLOSE call is issued. In high volume, transaction-based systems like CICS and IMS, this can impact performance severely.

    If the SHUTDOWN call is issued when the CLOSE call is received, the connection can be closed immediately, rather than waiting for the 30-second delay."

    I've not used it myself (that I can recall!), but here's some example COBOL code I found on the web (http://ezasoket.googlecode.com/svn-history/r18/trunk/test/src/listen02.cbl):

    <pre class="jive-pre"> MOVE 'SHUTDOWN' TO EZA-FUNCTION MOVE +0 TO EZA-ERRNO MOVE +0 TO EZA-RETCODE MOVE +2 TO EZA-HOW CALL 'EZASOKET' USING EZA-FUNCTION EZA-S-ORIGINAL EZA-HOW EZA-ERRNO EZA-RETCODE END-CALL MOVE EZA-FUNCTION TO CURRENT-FUNCTION MOVE EZA-ERRNO TO CURRENT-ERROR IF EZA-RETCODE IS LESS THAN +0 DISPLAY "SHUTDOWN failed with retcode " EZA-RETCODE " errno " EZA-ERRNO UPON CONSOLE GO TO AB-0001 END-IF </pre>
    Thank you very mnuch for this information.