tags:

views:

47

answers:

2

Hi, 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.

+2  A: 

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..

wallyk
Agreed that it would be organization dependent. Just wondering how common this use case is :)
shiouming
A: 

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. :)

Tim McClarren
Yup, I got what you mean :)
shiouming