There's no definition of $socket in your code as listed so it can't be run as it stands (at least, not to a smooth conclusion).
Help us to help you:
- Provide a Short, Self-Contained, Correct Example
- Use strict. Always.
- Avoid the perl4isms which exist in the code you've listed. These detract from the legibility of the code and might be the cause of problems which are less familiar these days.
- Maybe one or two comments explaining why you have chosen the methods you have, eg: why call &POSIX::_exit(0) rather than exit 0?
A look at the rest of the Basic debugging checklist will stand you in good stead as well. Once we have a runnable code we can test there will be a better understanding of the problem on both sides.