There is now a server host, it is necessary to real-time detect LAN host (1000) state of the switch machine, and need to communication with them, now the idea is:
Server: the server software installation, there's a TServerSoket components (stNonBlocking mode), and all service machine communication, there is also a TIdICMPClient, periodic ping each client IP
Client: install the client software, random start, there is a TClientSocke components, active connection TServerSoket,
The question now is:
1 the service side ping each client is not stable, most of the time can ping, sometimes can't ping;
2 TServerSoket read event there may be exceptions,
Help the old driver,
CodePudding user response:
Use of heartbeat, connect,
CodePudding user response:
reference 1st floor lyhoo163 response: using the heartbeat, connect, I now is such, as long as the client has launched, and every n seconds to give the server send a message CodePudding user response:
reference 1st floor lyhoo163 response: using the heartbeat, connect, Eldest brother, can give a contact, I pay to ask some questions, such as: I use in the thread TIdICMPClient. Ping the host, but is not stable, sometimes clearly boot, but can't, Also can add my QQ: 306068056, thank you, CodePudding user response:
Your judgment is switch machine status, not through lton-us state, if the boot but network impassability, heartbeat bag and not to be able to pass is to turn it off CodePudding user response:
Thanks for the two reply, Start my train of thought is both: 1 server active use TIdICMPClient. Ping to detect the state of the switch of the client machine (up to know in time, shut to also want to know in time, now would be a problem: when switched on, under the CMD can ping, but my application to the exception: Socket Erro 10040: Message too long, some say TIdICMPClient does not support multithreading, some say it's Indy bugs, has yet to find a solution). 2 since the launch of the client after startup, take the initiative to send server heartbeat, get their latest status (application requirements, the client may have already been booked, if you are scheduled, the client will jump out to full screen lock screen, don't let others use), at the same time, the service side as long as received the client's heartbeat, it shows that the client must be switched on, Now, it seems, article 1, the service side take the initiative to open multiple threads (each client a thread, according to the IP) ping client is superfluous, here is my ping method, called in a thread, please correct me, {test IP address can PING} The function ping (url: string) : Boolean; Var I: Integer; RST: Boolean; Err: String; IcmpClient: TIdICMPClient; The begin I:=0; RST:=False; IcmpClient:=TIdICMPClient. Create (nil); IcmpClient. ReceiveTimeout:=500; IcmpClient. Host:=url; IcmpClient. PacketSize:=1024; //ABuffer: url=+ StringOfChar (', 255); While (not RST) and (i<3) do The begin Inc (I); Try IcmpClient. Ping (); Application. ProcessMessages; If (icmpClient. ReplyStatus. FromIpAddress=url) then The begin RST:=True; End The else The begin RST:=false; Sleep (10); The end; Except, On e: the Exception do The begin Err:=e.M essage. //Socket Error # 10040 Message too long. Is can't the normal timeout exception when If pos (' 10040 ', err)=0 then Logger. The Log (url + 'abnormal Ping: + err); RST:=False; Sleep (10); The end; The end; The end; Result:=RST; IcmpClient. Free; The end; CodePudding user response:
Now see step 1, the service side active ping also is redundant, because of the possible client does not start randomly, or delay a few minutes to launch, Client number (100-1000), is not my control, my client program is free installation, by others on the client, set up the boot startup, CodePudding user response:
I also doing the same function, I am the WINDOWS API to implement the PING CodePudding user response:
Advice on the client to establish a heartbeat, server receives the heartbeat information, such as the heart 3 minutes at a time, Server-side processing: 1, establish a client list, record the IP and user name, the heart time, 2, the received data, contrast the client list, if no added, have to update the heart time, 3, scan client list regularly, heartbeat time more than 3 minutes are not receiving, determine the logoff, delete from the list, CodePudding user response:
Suggested IdIPMCast, report the status of their client every few seconds, the report shutdown is turned off, don't report is lost in overtime CodePudding user response:
The heartbeat is a common practice CodePudding user response:
You are to detect whether certain IP computer boot in local area network (LAN), or to test in some computers on your network client software is running, are not entirely equivalent, this If the former, don't use ping, ping, because firewall Settings can not response SendARP can be used to obtain the physical address (MAC address) of the other party, if successful, the other computer is connected to the Internet, in order to prevent Windows vista or after the use of local cache ARP table, can first DeleteIpNetEntry SendARP again, If the latter, the client software can monitor a port, shake hands if received specific data (their definition), it returns a specific response, so the service side polling in IP network, can know what the client starts, CodePudding user response:
Thank you for your reply, I will try to SendARP method, CodePudding user response:
Also can consider connection will try, but this may be the server pressure is bigger! And but not sure each other is shut down, is that way might interrupt the communication, the client software to turn off this kind of circumstance can use Telnet to determine whether to turn it off, CodePudding user response:
An application layer protocol, called SNMP, a lot of equipment including host, servers, switches, routers, printers are support of the agreement, Through this agreement, can do trap interval to specify the IP address of the sending state information, Through the agreement can also draw in the network topology, even learned that the state of the switch port, CodePudding user response:
This application had better use UDP send a heartbeat packets, no connection is established, more than how much time no heartbeat package was jailed for shutdown can More than 1000 sets of machines, if the TCP, your load switches, UDP is the right path, If using winsock, the UDP does not need any controls, with several functions of the winsock pool directly solved CodePudding user response:
Written in a socket server and client, why TIdICMPClient, The idea is as follows: Server server open port has been listening to the client machine and run the client, register and regularly sends a heartbeat packet to the server and open port to listen to myself at the same time, the server is the client's registration information, after receiving client to heartbeat package, if more than long time have not received, can be connected to the client port against the past, or ping client also line of ping simple] [call system, Of course, if the client is too much, suggest using short links, CodePudding user response:
A month before post? This version of the popular low, CodePudding user response:
The cited the 17th floor newpeng reply: posts a month ago? This version of the popular low, Send in September 1,,,, Delphi is not popular, CodePudding user response:
Popularity depends on everybody!!!!!! CodePudding user response:
I'll add some popularity: van master all 8... null