fixed the bug where closing a socket leads to crashes and added version shimming macros