Home > Back-end >  Delphi7 tcpserver more client connection
Delphi7 tcpserver more client connection

Time:02-04

Recently made a TCP communications procedures, Delphi first TCP, and multiple is a server to the client (1000) connection communication, I look at the delphi7 under which netchat routines, is used in Delphi's own tcpsever and tcpclient components, but only the one-to-one communication, and how to implement a one-to-many communication? Online in tcpsever end with multithreading, but I don't know how to create multiple processing threads, warrior can give directions, a code is best, thank you.

CodePudding user response:

Idtcpsever himself has a multithreading is blocked, however, in the order of magnitude smaller concurrent access, directly in idtcpsever excute method to deal with conflict of resource access

CodePudding user response:

Consult the socket example here:
http://download.csdn.net/detail/geoff08zhang/4571358

CodePudding user response:

With idtcpserver, synchronous development is convenient, but is not suitable for processing a large number of client connections, because inside is a link to a thread processing, thread is wasted too much time on the thread,
Or processing can use message pattern or patterns of events, under Windows iocp is one of the best performance,

CodePudding user response:

1000 connections, it estimated difficult

CodePudding user response:

It depends on your work environment is a LAN or wan, if it is a local area network (LAN), perhaps you can use the UDP way from server to all clients broadcast, it depends on what your application is, UDP broadcasts is the most efficient way,

If you wan, you won't be able to use UDP broadcast, as the upstairs said, want to support 1000 connections in a TCP way is difficult, a accommodating way is to use multiple ports connect 1000 spread out, but your server must support multiple ports,

CodePudding user response:

Tcpsever can connect multiple clients,
You first create a fifo circular buffer, and then create a buffer for each client, to save the data to the corresponding buffer, and then doing a separate thread to handle the data in the buffer.

CodePudding user response:

1000 connections to go asynchronously, using the iocp model easily support,

CodePudding user response:

IdTCPServer can also get 1000 links

CodePudding user response:

IdTCPServer blocking mode, 1000 connections will be 1000 threads, the operating system on the threads of a context switch is a huge cost, let alone or the server side, you also provide a lot of computing services,
  • Related