Shouldn't this be >= 0 ? Seems like you can get sockets with socket id 0.