Highlighted
Absent Member.
Absent Member.
1025 views

[archive] C$SOCKET Not Creating Server Socket

[Migrated content. Thread originally posted on 21 August 2007]

Hi there folks.

I'm trying to integrate software written in Java (my fluent language) with AcuCOBOL. Our company is currently using AcuCOBOL version 7.2 targeting Windows, Unix and Linux. We've made a few attempts using the CVM, but though it works as advertised on Windows, it seems to throw up some issues under Unix.

So I've implemented a lower-level solution which requires using C$SOCKET to create a server socket. The java software runs within Tomcat (deployed as a JNDI resource and consumed by web applications), and this kicks off the COBOL program (JSRVSOCK) containing the C$SOCKET call in a separate process :-
Process p = Runtime.getRuntime().exec( "runcbl -b JSRVSOCK" );

The problem is that this requires the COBOL to do something like this :-
CALL "C$SLEEP" USING 3.
before doing the C$SOCKET call to create the server socket, otherwise the socket fails to materialise failing with an AGS-EADDRINUSE error, even though a netstat shows that the chosen port is unused. The C$SLEEP makes it work as long as the process is kicked off as Tomcat is started. If the process is kicked off at some later point, during some web application activity for example, the socket creation fails regardless.

If the runcbl -b JSRVSOCK is executed at a Unix command prompt, the socket creates okay.

If the java Runtime exec is done from within a small test java program, again the socket creates okay.

Has anybody seen this behaviour before, or can offer any insight which might explain this unusual behaviour? Thanks in advance.

Tim
0 Likes
2 Replies
Highlighted
Absent Member.
Absent Member.

RE: [archive] C$SOCKET Not Creating Server Socket

Tim~ I am not clear as to what problem you are describing. I use C$SLEEP '0.5' prior to C$SOCKET in some instances to avoid a synchronization problem with authenticated SMTP. Is the 3 seconds too much delay? Or what?

~Jim
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] C$SOCKET Not Creating Server Socket

Thanks Jim.

I suppose I'm unnerved by having to do a seemingly spurious 'sleep' command to get it creating a socket. A sleep of about 1 second suffices for a socket created as Tomcat boots up, yet isn't when attempting to create a socket later, on demand, when Tomcat is fully up and running. For this latter, since it would be created on behalf of a waiting client request, having to do a sleep of any kind is worrying, and even if 3 seconds worked, it would leave the user waiting for at least that long.

Tim
0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.