prevent SOCKET leak in BindListenPort()

- the call to CloseSocket() is placed after the WSAGetLastError(), because
  a CloseSocket() can trigger an error also, which we don't want for the
  logging in this two cases
Merge pull request #4551

c994d2e prevent SOCKET leak in BindListenPort() (Philip Kaufmann)