made pid optional, will use posix_getpid for pid if argument is null
changed output
some refactor and better error catching
made receive and send methods into separate object controlled by service