Welcome Serena Central users! CLICK HERE
The migration of the Serena Central community is currently underway. Be sure to read THIS MESSAGE to get your new login set up to access your account.
vaci Absent Member.
Absent Member.
2746 views

Example programming named pipes on MF Acucobol-GT Version 9.1

Hi folks,

I should to build a connection between AcuCobol and Tcl via named pipes on the Windows platform. I have succesfully written a server part and the client part in the Tcl to be sure that the named pipe processing is running okay. Now one part (from case to case as server or client) should run in AcuCobol. In the AcuCobol documentation like "A guide for interoperating with Auccobol", Chapter 6.6.3 there are some sentences like:

"

Named pipes can also be used on Windows systems. You create Windows

pipes with the CreateNamedPipe( ) API. You can then use the CreateFile(

) API to access the other end of the newly created named pipe."

But I had no success with it. So I ask for an example what shows what DLL must be loaded, how to create, connect, write or read the pipe.

The best way with the displaying the actions like my example down.

Thank you very much.

Vaci

#-----------------------------------------------------------------------

      # pips.tcl - test twapi -  named pipe server              

      #-----------------------------------------------------------------------

      # step  action          Tcl                    

      #   1   wish pips.tcl   press Start        create 2 pipes

      #   2                        press Output     send to pipc.tcl

      #   3                        press Input       display from pipc.tcl    

      #----------------------------------------------------------------------

      package require twapi

      set f14     ariel-14

      set f12     ariel-12

      set t        "Test named pipe SERVER unter Windows"

      labelframe  .lf  -text $t          -width   200 \

                       -font $f14        -height  100

      button      .lf.s     -text Start        -command do_start   -font $f12

      button      .lf.i     -text Input        -command do_input   -font $f12

      button      .lf.o     -text Output       -command do_output  -font $f12

      label       .lf.l     -text "sendtime"                       -font $f12

      label       .lf.r     -text "receive "                       -font $f12

      button      .lf.e     -text End          -command do_ende    -font $f12

      pack  .lf.s .lf.i  .lf.o .lf.l .lf.r .lf.e -side left -padx 15

      pack        .lf

      proc do_output {} {

           set     a [expr [clock seconds]]

           puts  $::ou $a

           flush $::ou

           .lf.l configure -text "sended:$a" -bg green

           .lf.r configure                   -bg white

          }

      proc do_getsock {} {

           set msg "kein getsock"

           set msg [getSock]

           .lf.g configure -text $msg -bg yellow

          }

      proc do_input {} {

           if {[gets $::in record] < 0} {

               return

            }

           .lf.r configure -text "received:$record" -bg green

           .lf.l configure                          -bg white

          }

      proc do_start {} {

#          set     a [expr [clock seconds]]

            set    ::npw "\\\\.\\pipe\\CfrT"

            set    ::npr "\\\\.\\pipe\\CtoT"

           .lf configure -text "$::npw $::npr"

           set ::ou [::twapi::namedpipe_server $::npw -access {write}]

           fconfigure $::ou -buffering line -translation crlf -eofchar {} -encoding utf-8

           fileevent    $::ou writable [puts "$::ou writable"]

           .lf configure -text "$::npw $::ou"

           set ::in [::twapi::namedpipe_server $::npr -access {read}]

           fconfigure $::in -buffering line -translation crlf -eofchar {} -encoding utf-8

           fileevent    $::in readable [puts "$::in readable"]

            .lf configure -text "$::npw $::ou $::npr $::in"

   #--------------------------------------------

            pack forget  .lf.s;  # start done

      }

      proc do_ende {} {

           close $::ou

           close $::in

           exit

      }

#ende

test

0 Likes
6 Replies
mfisher Absent Member.
Absent Member.

RE: Example programming named pipes on MF Acucobol-GT Version 9.1

I've never done anything with Windows API calls from COBOL, but I think you would need to load kernel32.dll with the CALL statement. Then you should be able to use further CALL statements to call the Windows pipe functions that are documented here:

msdn.microsoft.com/.../aa365781(v=vs.85).aspx

Not sure if that link applies to the Windows version you're running. The MSDN site has changed a lot since I was last doing Windows desktop development.

I'm not a Micro Focus employee. Just thought it was an interesting thread, and would be interested to see if you can get it to work.

Named pipes are pretty trivial to use in Unix-like operating systems, but it looks a little hairy in Windows. I wonder if maybe C$SOCKET would be easier to program in Windows.

0 Likes
mfisher Absent Member.
Absent Member.

RE: Example programming named pipes on MF Acucobol-GT Version 9.1

Another thought: A SPOOL_FILE is a pipe. Ordinarily the SPOOL_FILE configuration technique is used to send output to an lp command. But we've used this technique in Linux to write output from ACUCOBOL to a PDF conversion utility. The external program receives data on its standard input stream, and receives EOF when ACUCOBOL closes the SPOOL_FILE..

documentation.microfocus.com/.../BKUSUSCONFS264.html

0 Likes
mfisher Absent Member.
Absent Member.

RE: Example programming named pipes on MF Acucobol-GT Version 9.1

Sorry, setting up a pipe via the COBOL configuration file only seems to work in Linux. And the SPOOL_FILE is not strictly necessary to use that technique. I'll pipe down now!

0 Likes
Micro Focus Contributor
Micro Focus Contributor

RE: Example programming named pipes on MF Acucobol-GT Version 9.1

mfisher above was correct - before you can call any function in kernel32.dll, you need to load that DLL (by calling it): You don't need to save the handle like you would if you were using LoadLibrary/GetProcAddress. Once the runtime has called a DLL, all the functions in that DLL will be available to call.

0 Likes
vaci Absent Member.
Absent Member.

RE: Example programming named pipes on MF Acucobol-GT Version 9.1

Thanks, but I do load the kernel32.dll before and the loading is succesfull.

The docu says that named pipes will be used for a connection between Acu and Java, so it should work.

Only what I need is one example for the CALL for the Function CreateNamedPipe - if it is running the next

functions can run too.

test

0 Likes
vaci Absent Member.
Absent Member.

RE: Example programming named pipes on MF Acucobol-GT Version 9.1

Hi, yes it is trivial with Linux I use named pipes for the connection betwenn MF-Cobol und Tcl/Tk since

long time. About sockets - I think you cannot give a socket the name, so it is not easy to control the trafic

or ?

Thanks for your work.

test

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.