For network programming do less, use the indy simple wrote a deal with the application update server, to indy's principle of work as well as some confusion
1. Indy server and client, speaking, reading and writing must be one to one?
For example, the client sends a command to the server, the server may send call write content for many times, the client should be carried out, in turn, receive, and clearly know what's the server passed, otherwise, the client feign death or the next read read the content of the error,
This send what content, and how to receive, is the concept of the so-called "communication protocols"?
2. Because indy is blocking type, does that mean the client if you want to have a good customer experience, is to make it multithreading commonly?
CodePudding user response:
If it is to use TCPServer, can write the sending and receiving understood as stream flow and read, a byte if confusion can not be recovered,
INDY client with multithreading,
CodePudding user response:
1. Indy there are a lot of things, and not to the server and client using in pairs, such as FTP or HTTP, you can only use the client, such as TIdHTTP access a web site, even the TCP protocol, also can not to use, as you already have a VC write TCP server program, so you can write a client only tcpclient,
2. Simple or can not multithreaded, such as a few minutes before you receive a few dozen bytes, completely don't need to make a multi-threaded, customers don't feel,
You mean like to write a program that automatically updates, general can write a web page on the server, and then use TIdHTTP access to this web page, analysis content need not to need to update, then download the files need to be updated,
CodePudding user response:
1. Don't have to be 1 to 1, such as SMTP, can directly use it connects 163, qq, etc. If write their own service and the client and define the first are the commands and represented by the function, and then according to the received command to make different movements, Communication basic response patterns to make it, namely the request is the response to the
2. It depends on what's function, like IdTCPClient is to use thread to read
CodePudding user response:
I want to write a server, file update service is just the server of a service, other services may also include: image transfer service, message service, database services, etc...
For example: Command format file service: fup://Check? FileName=a.e xe& The UserName=sea Photo service command format: PIC://GetPic? PicName=ABC001 Message service command format: MSG://Chat? . Database service: DBS://dbname=db1? Query...
Similar like this idea, and then the service on the server to register idTcpServer according to client's request, assign tasks to the corresponding service to respond