Home > Back-end >  Use the indy
Use the indy

Time:10-14

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

CodePudding user response:

Ha ha! RemObject!!!!

CodePudding user response:

The
reference 4 floor response:
I wanted 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& amp; The UserName=sea
Photo service command format: PIC://GetPic? PicName=ABC001
Message service command format: MSG://Chat? .
Database service:...

INDY server-side EXEUTE method itself is written in the thread, the client had better have a listen thread, the client will not block, because your main thread there are many other things to do, and the client is not always have data can be read
About protocol defines, you will see yourself but like you in the above definition of those protocols can't be sure, some like a custom protocol, but it is not used for network transmission, is more like a local call, do not know whether you can understand

CodePudding user response:

1. Yes, need to "communication protocol,"
2. The client to prevent blocking interface, can use TIdAntiFreeze controls to solve,

CodePudding user response:

See the demand of the building Lord, I think you use HTTP is more suitable, you can see TIdHttpserver and TIdHttp. Because using HTTP is simple, you don't have a lot of things

CodePudding user response:

refer to 6th floor response:
INDY server-side EXEUTE method itself is written in the thread, the client had better have a listen thread, the client will not block, because your main thread there are many other things to do, and the client is not always have data can be read
About protocol defines, you will see yourself but like you in the above definition of those protocols can't be sure, some like a custom protocol, but it is not used for network transmission, is more like a local call, do not know whether you can understand


Thank you, I is the basic idea of this server don't just do a simple service, so I didn't have this design idea, now do in dealing with the use of "broken" server implements a simple message and file update service, of course, I know that if add data set pass, work difficulty is big,

Design train of thought is:

1. The client sends the command, the command string to the demand of service and the command and parameter
2. The server response and analysis command, according to different service needs call, then put the command and parameter passed to the service
3. In the service according to the specific tasks to command and parameters, return the content of the need to pass to the client

My mind is confused, how to define a set of transmission "agreement", make each task is special to send and receive the order

CodePudding user response:

If you want to do the client can passively accept server relay messages and content, add a server listening on port on the client is a better choice? Otherwise is not only regular polling will send a message to the server?

CodePudding user response:

Indy server control is absolutely dynamic multi-threading,

CodePudding user response:

references 9 f searoom response:
refer to 6th floor response:
INDY server-side EXEUTE method itself is written in the thread, the client had better have a listen thread, the client will not block, because your main thread there are many other things to do, and the client is not always have data can be read
About protocol defines, you will see yourself but like you in the above definition of those protocols can't be sure, some like a custom protocol, but it is not used for network transmission, is more like a local call, do not know whether you can understand

Thank you, I is the basic idea of this service...

In fact you don't have to do it completely, it is ok to define several Record
For example:
CMD=(cLogin cUserList);
TLogin=record
The UserName,
Password: string [255];
end;

TUserList=record
The UserList: array [0.. 1024] of char;
end;

Packets that
The command name, data length, data, check.

CodePudding user response:

Indy both server and client
In contract module, callers are asynchronous
Even if he might use inside the synchronous socket mode

CodePudding user response:

Lz's idea is right, details, suggest indy directly read the source code, ask not what of, here
Indy is a blocking socket model, that is, until the send or recv completes, otherwise the function will not return,
Indy method of using multithreading + server implementation of block, that is to say the send and recv is relative to his own thread,
  • Related