Question & Answer
Question
How to implement 'Sockets' in Rational Rhapsody?
Answer
A Sockets application programming interface (API) comprises a library for developing applications in the C programming language that perform inter-process communication, most commonly for communications across a computer network.
Rhapsody's framework defines OSAL classes that can be used to implement sockets. For RiC it is the 'RiCOSSocket' class and for RiCpp it is the 'OMOSSocket' class. Both the classes have the various functions with respect to handling socket programming. The framework files have the implementation of the various socket handling functions which can be used as per requirement.
Attached are two RiC projects (server and client models) showing the implementation of Sockets.
These examples use the library WSOCK32.LIB and the header file "winsock.h" as provided by Microsoft for socket communication. I have used “Microsoft Visual Studio 2005” environment to test these attached examples. However, others can also be successfully used. The include directory path for the “DefaultComponent” may change if a different Microsoft compiler (or environment) is used.
The server and client programs as shown in these examples are two independent applications communicating over the port “52051” on the local host (127.0.0.1). To see the correct output, first create an executable for both the projects (Re-Generate & Make). Run the server application, and then the client application. Keep both the command windows (client/server terminals) side by side and type in a message in the client terminal. Observe the output.
Product Synonym
Rational Rhapsody
Was this topic helpful?
Document Information
Modified date:
27 May 2022
UID
swg21398197