//this is server side code snippet used for chat application
int* sockPtr;
int result;
result=listen(sClient,10); //sClient is SOCKET that is bind to specific port for listining incoming connection
sockPtr = (int*)malloc(sizeof(int));
*sockPtr= accept(sClient,(SOCKADDR*)&client_info,&addrlen); //here is the problem on sockPtr [which is integer type pointer]
但是當客戶端試圖連接有一個例外說異常而調用accept()
Unhandled exception at 0x0041ce6b in server.exe: 0xC0000005:
Access violation reading location 0x0000000.
我該怎麼辦?
我建議你檢查函數中的所有參數和返回代碼,看看它們是否都可以。 –