I'm sorry if this question has been asked before, but the idea is hard to formulate. I can understand how two computers can directly interact by listening to open ports and sending information directly to IP addresses. However, I want to know how applications like LogMeIn or chat applications communicate (through port 80 I'm guessing because it is always open, but you aren't allowed to listen to it), or even games (If they don't open a port). If I was to guess, I would think that they use a third party web server with a database that mediates the transfer of information between the computer by "GET"ing and "POST"ing requests. That would probably make the communication asynchronous.
I don't care if I get a bad rating for this question so long as I can get an answer, even if it is just a link to some开发者_高级运维where else that has the answers. Also, I work in C++ mainly and I am familiar with TCP and HTTP protocols.
Yes, generally there is a 'server' that multiple clients connect to. The server accepts messages from one client and forwards it to one or more other clients. This is almost always 'asynchronous' but that can mean a few things (whether it is done that way on the client or server, whether the server is 'event driven' or multithreaded, etc). The server can be a web server, but other kinds exist (Jabber servers for example, which use XMPP, usually [or often] on port 5222).
Some messengers work over HTTP (usually port 80, usually open) and even when a protocol usually uses a different port, a 'web gateway' can be written to communicate over port 80 and HTTP to avoid problems with other ports being blocked, and it can forward to the 'standard server' or re-implement it entirely. Especially in corporate environments, internet access can be me mediated by an HTTP proxy server so using a gateway or native HTTP messaging apps/protocols is the only option.
I guess it's important to define 'server' correctly for these discussions. Often the term is used to describe an actual computer, sitting in a data center or something. But when we talk about a 'web server' or 'jabber server' we usually mean a software daemon that is a piece of software who's job it is to listen for client connections and act on the messages it receives.
You're right that it's common to have a server which relays information between clients. IRC works that way, and most online games. And some applications do use HTTP just to avoid firewall troubles.
All communication on the Internet is inherently asynchronous: after you call a function to write to a socket, your program continues running while the packet travels to its destination.
Another alternative is a peer-to-peer network where a central server will negotiate a direct connection between two clients, and mainly serve as an arbiter for the status of the clients and their associated direct link rather than as a proxy or middle-man forwarding messages between clients. So a client will send a request to the central-server asking for a connection to another client, and the server will find that additional client from a pool of clients looking for other peers to connect to, and send the information for each individual machine back to the opposite client, at which point the clients themselves will make a direct connection to each other. Once the peer-to-peer conection between the two clients is established, the server may then maintain a "status" on the clients and their associated connections (i.e., there are X number of machines pulling from some individual client machine).
精彩评论