john miran
john miran

Reputation: 393

Data communication between COBOL and C#

I would like to build a communication protocol between COBOL and C# applications. I didn't find the right way to connect these two applications. The only possible way is to write data by COBOL to a file and read it by C# application and vice versa.

Can I use socket techniques to create such communication, because the file method has bad performance? Or are there any other methods of communicating data between these two languages?

Upvotes: 1

Views: 563

Answers (1)

Simon Sobisch
Simon Sobisch

Reputation: 7297

Can I use socket techniques to create such communication [...]?

Of course! You just need to make one a socket server and the other the client + creating + implementing a protocol (if it is just one client + server and you don't need secure communication this is quite easy). You may already have a socket option in your COBOL environment or use external libraries like the free CBL_GC_SOCKET (works for many COBOL implementations, as long as they can call C/C++ binaries).

Or are there any other methods of communicating data between these two languages?

A multitude (especially if they run on the same machine).

  • Depending on the COBOL environment used you may have a direct .NET-assembly option and CALL/invoke, or can write a layer to do so with running COBOL code translated to native code within C#.
  • Direct input/output is often a solution (depends on the needs and the environments, not all have a bi-directional pipe option).
  • talk to a message queue server (likely not superior in performance)
  • if the COBOL environment supports it: create a REST endpoint and use this for communication; or do it the other way around talking from COBOL to a REST service implemented in C# (REST from COBOL is likely the "most portable" way of those mentioned, but also the one with the worst performance)
  • ...

Conclusion: there is nothing that hinders COBOL to "communicate" with any reasonable "other programming language", you mainly have to see what you're COBOL and "other programming language" provides and what your goals are.

Upvotes: 1

Related Questions