Skip to main content

[archive] C$SOCKET Not Creating Server Socket

  • August 28, 2007
  • 4 replies
  • 0 views

[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

4 replies

[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
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

[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
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

[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
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

[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
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