Home > Software engineering >  TCP server listening on port expire after a long period of time
TCP server listening on port expire after a long period of time

Time:09-27

Use is ali cloud server, this problem is not the first time I found, when the cycle is long a few months time, at least a month, if it's a short is not only my own server, Microsoft netsh, also expire after a long period of time, someone encountered this problem?

CodePudding user response:

Ali cloud services for taobao fake

CodePudding user response:

Can look at system log syslog, or find ali cloud customer service

CodePudding user response:

Normal, won't appear this kind of situation,
If it happens, it is suggested that write a timeout mechanism,

CodePudding user response:

Nine times out of ten related to this API:
The GetTickCount
The GetTickCount function retrieves The number of milliseconds that have elapsed since The system was started. It is limited to The resolution of The system timer. If you need a who resolution timer, use amultimedia timer or a high - resolution timer.

DWORD GetTickCount (VOID)

The Parameters
This function has no parameters.

The Return Values
The return value is The number of milliseconds that have elapsed since The system was started.

Few
The following table describes The resolution of The system timer.

The System Resolution
Windows NT 3.5 and later The system timer runs at approximately 10 ms.
Windows NT 3.1 The system timer runs at approximately 16 ms.
Windows 95 and later The system timer runs at approximately 55 Ms.


The elapsed time is stored as a DWORD value. Therefore, The time will wrap around to zero if The system is run continuously for 49.7 days.

Windows NT: To obtain the time elapsed since the computer was started, look up the System up time counter in the performance data in the registry key HKEY_PERFORMANCE_DATA. The value returned is an eight - byte value.

QuickInfo
Windows NT: Requires version 3.1 or later.
Windows: Requires Windows 95 or later.
Windows CE: the Requires version 1.0 or later.
Header: Declared in winbase. H.
The Import Library: Use kernel32. Lib.

See Also
Time the Overview, Time Functions provides


Fyi:
 # pragma comment (lib, "NTDLL") 
# pragma comment (lib, "user32")
#include
#include
#include
#include
#include
#include
BOOL r;
Extern "C" NTSYSAPI NTAPI NtQuerySystemInformation (
IN UINT SystemInformationClass,//information type
OUT PVOID SystemInformation,//the buffer pointer
The size, IN bytes IN ULONG SystemInformationLength,//the buffer
The OUT PULONG ReturnLength OPTIONAL//of the number of bytes written to the buffer
);
//the first parameter is the request of information type, this parameter can have many values, in order to get the system startup time, we only use one of these values: SystemTimeInformation (3),
//if the first parameter is the SystemTimeInformation, the second parameter must be a SYSTEM_TIME_INFORMATION structure pointer,
Typedef struct {
LARGE_INTEGER liKeBootTime;//system be started time 1/10000 (in milliseconds),
LARGE_INTEGER liKeSystemTime;
LARGE_INTEGER liExpTimeZoneBias;
ULONG uCurrentTimeZoneId;
DWORD dwReserved;
} SYSTEM_TIME_INFORMATION;
SYSTEM_TIME_INFORMATION sti;
ULONG rl.
ULONG tk.
FILETIME ft;
//SYSTEMTIME lt;
//extern "C" ULONGLONG WINAPI GetTickCount64 (void);
//ULONGLONG tk64;
ULONGLONG d497;
# define days_of_2_32ms/49.71026962962962962962962962963/24/60 (2 ^ 32)/49.71026962962962962962962962963/60/1000=
Int main () {
NtQuerySystemInformation (3, & amp; Sti, sizeof (sti), & amp; Rl);//3==SystemTimeOfDayInformation
COleDateTime t, now;
Cstrings s, FMT="% % Y - m - H: % d % % m: % s".

Memcpy (& amp; The ft, & amp; Sti liKeBootTime, sizeof (LARGE_INTEGER));
T=COleDateTime (ft);
S=t.F ormat (FMT);
Printf (" Boot DateTime: % s \ n ", s);
Tk=GetTickCount ();//The elapsed time is stored as a DWORD value. Therefore, The time will wrap around to zero if The system is run continuously for 49.7 days.
Now=COleDateTime: : GetCurrentTime ();
T=now - COleDateTimeSpan ((double) tk/86400000.0);
S=t.F ormat (FMT);
Printf (" Prev GetTickCount () Wrap to Zero DateTime: % s \ n ", s);
S=now. The Format (FMT);
Printf (" GetTickCount () : 8 x %, Now a DateTime: % s \ n ", tk, s);
T=now + COleDateTimeSpan ((double) (0 xffffffffu - tk)/86400000.0);
S=t.F ormat (FMT);
Printf (" Next GetTickCount () Wrap to Zero DateTime: % s \ n ", s);
return 0;
}

CodePudding user response:

Could it be your server software, using the old xp period of APM broadcast messages to stop server to enter a dormant state?
The server if you have been so busy so no problem, but if there was a time during connectionless
The server will be forced to enter a dormant state

CodePudding user response:

Under Windows, the Listen function would pull in line (after the network is not available), failure,

CodePudding user response:

The GetTickCount
Others try overflow seems more than 40 days, a great number of overflow into the minimum, the program logic to kneel, or use GetTickCount64 range increases, longer, or in other apis

CodePudding user response:

refer to 6th floor euber2 response:
under Windows, Listen function would pull in line (after the network is not available), failure,

Add judge if failure code, when conditions permit, to listen

CodePudding user response:

nullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related