Use template for inet_sock events

TCP event in/out are exactly the same, except for their name. Simplify the code
by using template.

Signed-off-by: Francis Giraldeau <francis.giraldeau@gmail.com>