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.