in reply to Socket connection killing program

Try adding more error checking. Maybe gethostbyaddr is failing, and so the next line tries to dereference an undefined reference, for example.

Also, note that your script won't accept a second connection while the first is still running; it won't get back to the accept line until it's done reading from $client.