Study/에러 정리

Powershell) Server ping check with timestamp

Juzdalua 2025. 1. 15. 17:00

IOCP 클라이언트가 recv 과정에서 10053 에러로 접속이 끊겼다.

https://learn.microsoft.com/ko-kr/windows/win32/winsock/windows-sockets-error-codes-2

 

Windows 소켓 오류 코드(Winsock2.h) - Win32 apps

WSAGetLastError 함수에서 반환된 Windows 소켓(Winsock) 오류 코드입니다.

learn.microsoft.com

 

서버는 계속 살아있는데 클라이언트만 끊겼다.

여러 원인 중 하나로, 내부 인터넷 연결이 끊겼을 상황을 체크해보았다.

서버 IP로 핑테스트를 보냈다.

Ping 테스트가 실패했을 때, 동일하게 서버는 살아있는데 연결되어있는 클라이언트 모두 접속이 종료됐다.

 

while ($true) {
    $timestamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
    $serverIp = "127.0.0.1" # Change ip
    $pingResult = Test-Connection -ComputerName $serverIp -Count 1 -Quiet
    if ($pingResult) {
        Write-Output "$timestamp [$serverIp] - Ping Success"
    } else {
        Write-Output "$timestamp [$serverIp] - Ping Failed"
    }
    Start-Sleep -Seconds 1
}