If desired, you can facilitate communication between Java and COBOL programs on a socket level. ACUCOBOL-GT includes a library routine, known as C$SOCKET, to perform interprocess communication.
When calling COBOL from Java:
Of course, because the data format is totally open and undefined, the COBOL and Java programmers must agree on a common format.
Following is sample code to demonstrate this capability:
*The following code creates a server socket. CALL "C$SOCKET" USING AGS-CREATE-SERVER, 8765 GIVING SOCKET-HANDLE-1. *The following code waits for a connection. CALL "C$SOCKET" USING AGS-NEXT-READ, SOCKET-HANDLE-1, TIMEOUT. *If have a connection request. Accept the connection. CALL "C$SOCKET" USING AGS-ACCEPT, SOCKET-HANDLE-1. *Read data from the connecting socket. CALL "C$SOCKET" USING AGS_READ, SOCKET-HANDLE-2, SOCKET-IN, IN-DATA-LENGTH GIVING READ-AMOUNT. *Write outgoing data back to the client socket: CALL "C$SOCKET" USING AGS-WRITE, SOCKET-HANDLE-2, SOCKET-OUT, OUT-DATA-LENGTH.
See General Syntax and Library List for information on the C$SOCKET library routine.