Skip to main content

[Migrated content. Thread originally posted on 13 October 2011]

NetExpress 3.1/5.1 developer. I need to know which Win32APIs to call to:
Open a TCP/IP port on a target server
Send data to that server to request a response
Receive the response form the server
Send the next request ......
Close the link when finished

Being unfamiliar with what's required here I've taken a stab by browsing through the MSDN site, and have come up with a possible sequence of APIs to call, based on WinSock functions
WSASTARTUP to initialise the Winsock DLL
SOCKET to create a socket on IP (not sure how to connect to a particular port)
SEND to send data
RECV to receive the response, then round again to send more
CLOSESOCKET
WSAGETLASTERR to check errors

Am I oversimplifying here? Of course this needs to be completed yesterday; any help gratefully received ...

[Migrated content. Thread originally posted on 13 October 2011]

NetExpress 3.1/5.1 developer. I need to know which Win32APIs to call to:
Open a TCP/IP port on a target server
Send data to that server to request a response
Receive the response form the server
Send the next request ......
Close the link when finished

Being unfamiliar with what's required here I've taken a stab by browsing through the MSDN site, and have come up with a possible sequence of APIs to call, based on WinSock functions
WSASTARTUP to initialise the Winsock DLL
SOCKET to create a socket on IP (not sure how to connect to a particular port)
SEND to send data
RECV to receive the response, then round again to send more
CLOSESOCKET
WSAGETLASTERR to check errors

Am I oversimplifying here? Of course this needs to be completed yesterday; any help gratefully received ...
You are on the right track but instead of coding your program at the sockets level perhaps you might want to look at a higher level approach like that supported by 3rd party vendors such as:

MarshallSoft

or look into using Client Server binding CSBind of Net Express, if both client and Server pieces are COBOL.

Perhaps others can suggest more alternative approaches?


[Migrated content. Thread originally posted on 13 October 2011]

NetExpress 3.1/5.1 developer. I need to know which Win32APIs to call to:
Open a TCP/IP port on a target server
Send data to that server to request a response
Receive the response form the server
Send the next request ......
Close the link when finished

Being unfamiliar with what's required here I've taken a stab by browsing through the MSDN site, and have come up with a possible sequence of APIs to call, based on WinSock functions
WSASTARTUP to initialise the Winsock DLL
SOCKET to create a socket on IP (not sure how to connect to a particular port)
SEND to send data
RECV to receive the response, then round again to send more
CLOSESOCKET
WSAGETLASTERR to check errors

Am I oversimplifying here? Of course this needs to be completed yesterday; any help gratefully received ...
There are many pitfalls in using the sockets API directly. I don't recommend it, unless you want to make a major investment in becoming a sockets programming expert.

We don't have enough information to make a really good recommendation. Is there a reason you're looking at using raw TCP for this application? From your description, it sounds like you'd be better off using a higher-level protocol such as DCOM or HTTP.

I haven't worked with DCOM myself, but there are ample references, it doesn't require any additional third-party software, and I believe NX 5.1 includes a COBOL DCOM example and documentation. For HTTP, you could run IIS on the server and run your server program through ISAPI - again, there are examples and documentation in NX 5.1; the client could use a free HTTP client API such as libcurl (there's an MF Knowledgebase article about this) or Microsoft's own WinHTTP. Under NX 5.1 you could also map the server program as a web service and host it under MF Enterprise Server, and use NX to generate a client proxy.

[Migrated content. Thread originally posted on 13 October 2011]

NetExpress 3.1/5.1 developer. I need to know which Win32APIs to call to:
Open a TCP/IP port on a target server
Send data to that server to request a response
Receive the response form the server
Send the next request ......
Close the link when finished

Being unfamiliar with what's required here I've taken a stab by browsing through the MSDN site, and have come up with a possible sequence of APIs to call, based on WinSock functions
WSASTARTUP to initialise the Winsock DLL
SOCKET to create a socket on IP (not sure how to connect to a particular port)
SEND to send data
RECV to receive the response, then round again to send more
CLOSESOCKET
WSAGETLASTERR to check errors

Am I oversimplifying here? Of course this needs to be completed yesterday; any help gratefully received ...
Thanks for your responses; a relief to have a contact or two.

A bit more depth.... the application has to communicate with Reuters DTS (Deal Tracker Server).
It currently talks serially, and has remained unchanged for a decade. It call a .BIN to open/read/write/close the comm port.
The implementation is such that it never receives an unsolicited mesage - it sends, receives a reply, sends another - no complexity really.
The replacement needs to do exactly the same but via an IP socket connection. The format of the data sent and received is identical (except no BCC or ACK/NAK), so the surrounding COBOL code to break down and process the messages remains the same. So on the face of it seemingly simple ....

The one piece of documentation I have states the port number for the inbound connection, that can be varied via a config. That's it ....

Do I need to become a socketprogramming expert to achieve this?!

Thanks for any help offered!

[Migrated content. Thread originally posted on 13 October 2011]

NetExpress 3.1/5.1 developer. I need to know which Win32APIs to call to:
Open a TCP/IP port on a target server
Send data to that server to request a response
Receive the response form the server
Send the next request ......
Close the link when finished

Being unfamiliar with what's required here I've taken a stab by browsing through the MSDN site, and have come up with a possible sequence of APIs to call, based on WinSock functions
WSASTARTUP to initialise the Winsock DLL
SOCKET to create a socket on IP (not sure how to connect to a particular port)
SEND to send data
RECV to receive the response, then round again to send more
CLOSESOCKET
WSAGETLASTERR to check errors

Am I oversimplifying here? Of course this needs to be completed yesterday; any help gratefully received ...
Thanks for the MarshallSoft link. They have a product - CSC - for building almost any Client/Server structure; am well underway in modifying existing code to call CSC functions to attach/open/send/receive. So far so good

The product can be used to build just a client end to communicate with an existing Server app, which is what I required.

[Migrated content. Thread originally posted on 13 October 2011]

NetExpress 3.1/5.1 developer. I need to know which Win32APIs to call to:
Open a TCP/IP port on a target server
Send data to that server to request a response
Receive the response form the server
Send the next request ......
Close the link when finished

Being unfamiliar with what's required here I've taken a stab by browsing through the MSDN site, and have come up with a possible sequence of APIs to call, based on WinSock functions
WSASTARTUP to initialise the Winsock DLL
SOCKET to create a socket on IP (not sure how to connect to a particular port)
SEND to send data
RECV to receive the response, then round again to send more
CLOSESOCKET
WSAGETLASTERR to check errors

Am I oversimplifying here? Of course this needs to be completed yesterday; any help gratefully received ...
Development completed.

Excellent service from MarshallSoft on their CSC product - software calling their functions now deployed in production, and went live over the weekend.

Thanks again for assistance.

[Migrated content. Thread originally posted on 13 October 2011]

NetExpress 3.1/5.1 developer. I need to know which Win32APIs to call to:
Open a TCP/IP port on a target server
Send data to that server to request a response
Receive the response form the server
Send the next request ......
Close the link when finished

Being unfamiliar with what's required here I've taken a stab by browsing through the MSDN site, and have come up with a possible sequence of APIs to call, based on WinSock functions
WSASTARTUP to initialise the Winsock DLL
SOCKET to create a socket on IP (not sure how to connect to a particular port)
SEND to send data
RECV to receive the response, then round again to send more
CLOSESOCKET
WSAGETLASTERR to check errors

Am I oversimplifying here? Of course this needs to be completed yesterday; any help gratefully received ...
You are quite welcome!


[Migrated content. Thread originally posted on 13 October 2011]

NetExpress 3.1/5.1 developer. I need to know which Win32APIs to call to:
Open a TCP/IP port on a target server
Send data to that server to request a response
Receive the response form the server
Send the next request ......
Close the link when finished

Being unfamiliar with what's required here I've taken a stab by browsing through the MSDN site, and have come up with a possible sequence of APIs to call, based on WinSock functions
WSASTARTUP to initialise the Winsock DLL
SOCKET to create a socket on IP (not sure how to connect to a particular port)
SEND to send data
RECV to receive the response, then round again to send more
CLOSESOCKET
WSAGETLASTERR to check errors

Am I oversimplifying here? Of course this needs to be completed yesterday; any help gratefully received ...
hi,

while searching i found this article quite familiar to my problem.

i am new to microfocus and currently we have a task to access a legacy cobol library migrated to microfocus sun solaris environment. we have already purchased licences Micro Focus Server Express 5.0 on Sun Solaris 5.10.

as performance matters, i dont want to access it over web service with microfocus enterprise server.

for better performance we plan to develop a cobol application waiting for request via TCP/IP as an interface on unix and access legacy cobol library and return result the calling application via tcp/ip.

is this solution possible without purchasing ACUCOBOL-GT? is there any example cobol programs for tcp/ip server functions compiled on solaris microfocus without ACUCOBOL?


regards.


[Migrated content. Thread originally posted on 13 October 2011]

NetExpress 3.1/5.1 developer. I need to know which Win32APIs to call to:
Open a TCP/IP port on a target server
Send data to that server to request a response
Receive the response form the server
Send the next request ......
Close the link when finished

Being unfamiliar with what's required here I've taken a stab by browsing through the MSDN site, and have come up with a possible sequence of APIs to call, based on WinSock functions
WSASTARTUP to initialise the Winsock DLL
SOCKET to create a socket on IP (not sure how to connect to a particular port)
SEND to send data
RECV to receive the response, then round again to send more
CLOSESOCKET
WSAGETLASTERR to check errors

Am I oversimplifying here? Of course this needs to be completed yesterday; any help gratefully received ...
kemikcan originally wrote:

i am new to microfocus and currently we have a task to access a legacy cobol library migrated to microfocus sun solaris environment. we have already purchased licences Micro Focus Server Express 5.0 on Sun Solaris 5.10.


Server Express 5.0 is quite old. If you are under maintenance I would recommend updating to the current product (Server Express 6.0, Service Pack 2, Web Sync 1).

as performance matters, i dont want to access it over web service with microfocus enterprise server.


Have you actually tried this, and verified that performance is an issue? Or that your proposed approach offers better performance?

Of course, you haven't explained what you mean by "access" - what the client is, how the application is architected, what kind of traffic will be on the wire, how many clients will be involved, whether they're short- or long-running, whether their communication with the server will be short- or long-running, and so on. So we can only make the most vague and general recommendations.

for better performance we plan to develop a cobol application waiting for request via TCP/IP as an interface on unix and access legacy cobol library and return result the calling application via tcp/ip.


As I believe I posted earlier in this thread, writing a TCP/IP-based distributed application is a specialized skill. Reinventing this wheel is rarely the best option, particularly if you don't already have a developer who's experienced in this area already engaged.

is this solution possible without purchasing ACUCOBOL-GT?


Certainly. It's not trivial, since you'll have to either call the sockets API directly from COBOL (which is inconvenient), or you'll have to call a library written in some other language that talks to the sockets API for you. There are various third-party libraries for that purpose - many of them free - but they generally implement some higher-level protocol, and I have no way of knowing whether that's appropriate for what you need to do. You could also write your own.

ACUCOBOL is a separate product. It's possible that it's a better fit for your application, but again I really have no way to tell.

is there any example cobol programs for tcp/ip server functions compiled on solaris microfocus without ACUCOBOL?


I don't know of any.

Frankly, if I needed to expose a COBOL program as a server, and for some reason Enterprise Server wasn't suitable, I'd most likely host it under a web server as a CGI program. If I absolutely had to have it run as a self-contained TCP server, I'd write all the sockets code in C, and just keep the business logic in COBOL. I don't see much use in forcing COBOL to call APIs (like sockets) that aren't convenient for it.