简体   繁体   English

COBOL与C#之间的数据通信

[英]Data communication between COBOL and C#

I would like to build a communication protocol between COBOL and C# applications.我想在COBOLC#应用程序之间建立一个通信协议。 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.唯一可能的方法是通过 COBOL 将数据写入文件并通过 C# 应用程序读取,反之亦然。

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?或者还有其他在这两种语言之间传递数据的方法吗?

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).您可能已经在您的 COBOL 环境中有一个套接字选项,或者使用诸如免费的CBL_GC_SOCKET之类的外部库(适用于许多 COBOL 实现,只要它们可以调用 C/C++ 二进制文件)。

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#.根据所使用的 COBOL 环境,您可能有一个直接的 .NET 程序集选项和CALL /invoke,或者可以编写一个层来执行此操作,在 C# 中运行转换为本机代码的 COBOL 代码。
  • Direct input/output is often a solution (depends on the needs and the environments, not all have a bi-directional pipe option).直接输入/输出通常是一种解决方案(取决于需求和环境,并非所有产品都有双向 pipe 选项)。
  • 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;如果 COBOL 环境支持:创建一个 REST 端点并将其用于通信; 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)或者从 COBOL 到 C# 中实现的 REST 服务的其他方式(来自 COBOL 的 REST 可能是提到的那些“最便携”的方式,但也是性能最差的方式)
  • ... ...

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.结论:没有什么阻碍COBOL与任何合理的“其他编程语言”“交流”,你主要要看你是COBOL和“其他编程语言”提供什么,你的目标是什么。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM