I am implementing a messaging protocol between nodes on a network and i am wondering how to expose the messaging system interface to the programmers. The messaging protocol supports a set of commands that the clients and servers can exchange to get jobs done.
To be generic, let's says, for instance, the system supports 2 operations : REQUEST_OBJECT, MODIFY_OBJECT. To provide an interface, i have 2 choices : Whether to provide 2 distinct methods : request_object (handle, obj)
and modify_object (handle, obj, data)
or use a generic method : msg_ioctl (handle, COMMANDE, var_args ...)
, the number of variadic arguments var_args ...
and their interpretation depends exclusively on COMMANDE
so in this case we will have 2 different cases for the ioctl call : msg_ioctl (handle, REQUEST, obj)
and msg_ioctl (handle, MODIFY, obj, data)
.
What are the advantages and disadvantage of each option and what could be the possible flaws that can become visible in the long run taking in consideration different languages that are possibly to be used (To discuss things like argument type checking ...etc) to implement such a system ?