Which type of diagram is used for denoting Client / Server socket programming?

6.2k Views Asked by At

I have developed couple of socket based interactive web applications with my team but I have always found it a pain to document the conditional flow of data.

I have used Sequence Diagram like these Sequence Diagram Example

Is it the best way to document socket programming? Is there any UML standard for socket programming?

3

There are 3 best solutions below

3
On

Edit : It is not UML diagram but a simple Representation.

To create a connection-oriented socket, separate sequences of functions must be used for server programs and for client programs, so you can represent your socket connection as :

Socket.io

2
On

As an alternative to your SD you can try it with Interaction Diagram which puts a different focus on the communication (more state oriented). The single messages get numbered according to the call sequence.

Additionally you can create a Component Diagram where the single components use a port for communication and the ports realize certain interfaces. That also fits nicely with socket/lollipop notation. The data flow can also be show by using the Data Flow connectors where you can assign classes that show the transported data.

Sample

The picture above is probably none you would create in a real model. But it shows what you can do to enhance your model. There are two classes Server and Client which relate to the interface Socket (it should probably be called MailSocket to fit OP's model better) which realize/depend on the interface. Below the classes are shown two components which depend on them. Both show ports with either provided (lollipop) or required (socket) interface. This simply pictures (and needs to be detailed with separate diagrams) that the Component Server has the class Server in its stomach and exposes the interface realized by it (you will usually do that with a composite diagram). Analogously for Client computer/Client. The data flow between the component visualized that the Mail class is transported from Client computer to Server.

All in all, this is one example how to enhance a model describing a socket communication. There is no standard in describing socket I/O (or anything at all) in UML. UML is a language to communicate ideas. Here is just one example. There are endless other possibilities. Use whatever serves best. Experiment. Discuss.

0
On

Have you considered using a UML protocol state machine to show conditional flow of data? See http://www.uml-diagrams.org/protocol-state-machine-diagrams.html#protocol-state-machine .