I think that when the socket invalid, the return value should be -1.

For the return value
0:  to tell the caller none connection exist;
the positive number: to tell the caller the connection number
the negative number: to tell the caller some error for the server