socketsnetwork-programmingduplex

Full duplex socket vs. two sockets used, one for read and other for write


I was wondering,

1st question What are the pros and cons of using one socket (full duplex) vs. two socket (simplex) per peer: one for read and other write? Specially in terms of performance and resource utilization.

2nd question In case, if i choose to use more than 1 sockets per peer, on all i do read and write. Then will it helps me scale out in handling no of messages handled?

3rd question: what should help me determine the number of sockets per peer? Network Bandwidth? No. of message in and out?

All questions are different and do not have any inter-relation.


Solution

  • What are the pros and cons of using one socket (full duplex) vs. two socket one for read and other write? Specially in terms of performance and resource utilization.

    Pro one socket: resource utilization. Contra one socket: nil. Performance: identical, except that you save on connect and close handshakes if you only use one socket.

    In case, I choose to take two socket approach, then will not be useful to use both of them full duplex, that way it helps me scale out in terms of data flowing in and out?

    Now you're comparing apples and oranges. You can't compare one full-duplex socket with two full-duplex sockets. I don't know why you think you might need two inbound and two outbound flows, but you don't. Every protocol I can think of except FTP uses only one.

    what impact does network bandwidth has on it?

    Nil.

    or it has on network utilization?

    Nil, apart from the connect and close handshakes. But it wastes resources at both ends.