I made a window using WinAPI and it needs to enter message loop:
while (GetMessage(&msg, nullptr, 0, 0))
Exception thrown at 0x00000000 in test.exe: 0xC0000005:
Access violation executing location 0x00000000.
This is a very confusing question as it asks one question in the title, but the content addresses a different problem (threads crashing).
To address the primary question: Microsoft did add a way to handle socket communications in a GUI thread friendly way: WSAAsyncSelect. This will send socket events as messages to your applications message queue - typically an invisible window is created to handle the messages.