Unfortunately, this is not a coding service. What we will do is point you in the right direction to get you started though. If you want to interface with sockets, then you want to be examining a module like
this one. Remember, CPAN is your friend and Google is too.
Why not try to code what you are describing, then post your code here if you get stuck. (enclosed in the proper, necessary code tags).
Regards,
Jeff