In regular request/response between client and server, first a client initiates a request to server, then server responses. Assume that the server always knows the IP address of its clients (note that clients have dynamic IP address). Is it possible for server to initiate the request first? By "initiate the request first" I mean server must be able to send data to clients whenever wants. Thanks
Assume that you wanna transfer data (reliable) between two devices on the Internet. So the chances are TCP must be used. I have a device that has static IP address and many distributed(all connected to Internet, not in the same LAN) devices that don't have static IP address. All the distributed devices have the IP address of the central device so they can initiate a request to central device. I want the central device to send data to distributed devices whenever it wants. Thanks
To establish a TCP connection one end (the "server") listens and the other end (the "client") connects to it.
Once the TCP connection is established either end can send data to the other end whenever it wants.
In practice however your clients are likely to be behind firewalls or nats and that adds some complications.
It is unlikely that your server will be able to initiate a connection to a listner on the client. There are tricks that can sometimes be used but they don't always work.
If a TCP connection sits idle for too long then firewalls/NATs are likely to cut it off.
Certain network glitches can cause a connection to be cut off without the endpoints realising it is cut off.
The result is that if you are deploying clients on arbitary networks and you need the server (which we assume has an IP on the public internet) to be able to send messsages to them the clients need to establish a permanent TCP connection to the server and they need to periodically send a test/keepalive message to the server. IF they get no reply to their test/keepalive message then they need to tear down the TCP connection and try establishing a new one.
As Gerben mentioned in comment, in IP protocol there is no server or client. If you know IP and port of the client, then you can send data.
However, the client has to listen on some port, because otherwise the system doesn't know to which application are the data meant and it will just discard them.
So the answer to your question whether it is possible for server to initiate data transmission is yes and no. Yes it is possible, but your client has to listen on some port first, so you need the client running before you send data.
Edit: this is assuming your clients have public IPs or are on the same network as server. If they use NAT, then it would be more complicated.
Assuming you are talking about TCP/UDP, if you know both connection endpoints (IP and Port), you can do whatever you want with the nodes. Remember though, that to connect to a host, it has to be expecting a connection (the other host has to be listening in a specific port, so it would kinda act like a server too).
About what you said of persistent connections (keep-alive) it's an HTTP method to receive multiple HTTP requests and responses, so it's not what you are looking for. Anyways, this is a layer 4 protocol and I think it shouldn't be discussed here.