adapted close to windows closesocket
some adaption