Reputation: 1949
I am thinking to write a simple wrapper class for socket in C++. I wonder if there is a need to have concrete class specific to I/O type, such as TcpSyncSocket and TcpAsyncSocket. Thus I would like to know how often do you guys find yourself in need to have mixture of both kind I/O operations on single socket. While I do not have extensive experience in doing socket programming, probably I will drop the idea if this is simply the norm. Thanks.
Upvotes: 0
Views: 129
Reputation: 111
Reusable libraries that implement a "socket object" in C++ usually have a "setBlocking(bool)" method on the socket.
I think that's better than proliferating the class count by having different classes.
Particularly in light of the fact that blocking is one of about a bazillion other socket options you might want to add support for.
Then you have TcpSyncSocketWithLargeRecvAndSendBuffer, and TcpSyncSocketWithLargeRecvAndSendBufferResusable.
I think you see where I'm going here. :)
Upvotes: 0
Reputation: 57774
I've never written nor seen mixed use sync vs. async sockets. Ordinarily the usage is dependent on the program's organization, and that doesn't normally change throughout the lifetime of a socket..
Upvotes: 2