you should enclose program code in <pre>....</pre> to make it readable and non-damaged. the < character should be replaced by < to not get the rest of the line parsed as an invalid html tag. without indentation and with parts of the code missing few people will be inclined to read your code.
generally you should check if some function call/syscall failed just before the hang. there are still unchecked calls (e.g. close(), send()) and you could try a debugging mode with more logging and/or strace to get the full picture.
<pre>....</pre>
you should enclose program code in <pre>....</pre> to make it readable and non-damaged. the < character should be replaced by < to not get the rest of the line parsed as an invalid html tag. without indentation and with parts of the code missing few people will be inclined to read your code.
generally you should check if some function call/syscall failed just before the hang. there are still unchecked calls (e.g. close(), send()) and you could try a debugging mode with more logging and/or strace to get the full picture.