IdTCPServer has achieved two-way receive sending messages and IdTCPClient normal
After tested IdTCPServer IdTCPClient to send a message, if have any new client IdTCPClient TCPServer on the link will not
But have been connected IdTCPClient and IdTCPServer receiver is normal is a new open IdTCPClient connected not
Test 2
If no IdTCPServer sending messages with IdTCPClient directly send IdTCPServer message is very normal to open the new client
Still can connect in
If use IdTCPServer send IdTCPClient news new client will open connections less than
Who met this strange question
Please stretch your helping hand please also specify the problem where thanks
Only 105
Thank you to fill, so the
CodePudding user response:
Waiting for the master!
CodePudding user response:
Implement a similar system
1) the client has launched two road connection
A road used for ordinary communication (client==="server)
B road used to receive message from the server active
Do not understand QQ, 287413288
CodePudding user response:
How do you spell your server, sending INDY can support multiple,
CodePudding user response:
reference SQLDebug_Fan reply: 3/f how do you spell your server, sending INDY can support multiple, Procedure TForm2. Button2Click (Sender: TObject); Var I: integer; AContext: TIdContext; The begin For I:=0 to IdTCPServer1. Contexts. The LockList. Do the Count - 1 The Begin AContext:=TIdContext (IdTCPServer1. Contexts. The LockList. Items [I]); AContext. Connection. IOHandler. Write (' A '); The End; end; This is so with server sends the message CodePudding user response:
And one more thing I tested the If use the server sends the message Client endpoint buttons perform IdTCPClient1. Disconnect; Also send method normally open and exit If the server does not take the initiative to send message to the client is normal Said to is cannot use the server to the client actively send messages CodePudding user response:
I see indy9 example own Chat program, the client will also be suspended animation CodePudding user response:
You write a response in the event of OnRead server? CodePudding user response:
INDY is one thread per connection, does not stop using thread receives the data, the above said is wrong, is in OnExecute method, has been continuously receive calls Read the client sends data, CodePudding user response:
The reference 7 floor SQLDebug_Fan response: did you server in the event of an OnRead write a response? Procedure TForm2. IdTCPServer1Execute (AContext: TIdContext); Var Hb: TIdIOHandler; TempStr: TStrings; The begin Hb:=AContext Connection. The IOHandler; If Not Hb. InputBufferIsEmpty then The Begin Hb. CheckForDisconnect (True, True); Hb. ReadStream (RStream, Hb. InputBuffer. Size); TempStr:=TStringList. Create; RStream. Position:=0; TempStr. LoadFromStream (RStream); Memo1. Lines. AddStrings (TempStr); TempStr. Free; RStream. The Clear; The End; Sleep (100); end; This is my code from the server, the server receives no problem The key is if use the server to send the other new client will open connected not CodePudding user response:
You send and receive is separated? CodePudding user response:
I have not used it, I was only Delphi TTcpServer and TTcpClient, very good, not as Indy from time to time to jump out of a problem, CodePudding user response:
I don't remember the client all day monitoring port, only in the link when receiving a message, CodePudding user response:
references 9 f gfuchao response: Quote: refer to 7th floor SQLDebug_Fan response: You write a response in the event of OnRead server? Procedure TForm2. IdTCPServer1Execute (AContext: TIdContext); Var Hb: TIdIOHandler; TempStr: TStrings; The begin Hb:=AContext Connection. The IOHandler; If Not Hb. InputBufferIsEmpty then The Begin Hb. CheckForDisconnect (True, True); Hb. ReadStream (RStream, Hb. InputBuffer. Size); TempStr:=TStringList. Create; RStream. Position:=0; TempStr. LoadFromStream (RStream); Memo1. Lines. AddStrings (TempStr); TempStr. Free; RStream. The Clear; The End; Sleep (100); end; This is my code from the server, the server receives no problem The key is if use the server to send the other new client will open connected not Your server has a problem, How can use Memo1?? These turn into the synchronous thread!! CodePudding user response:
Procedure TForm2. Button2Click (Sender: TObject); Var I: integer; AContext: TIdContext; The begin For I:=0 to IdTCPServer1. Contexts. The LockList. Do the Count - 1 The Begin Try////add the try to filter certain error AContext:=TIdContext (IdTCPServer1. Contexts. The LockList. Items [I]); AContext. Connection. IOHandler. Write (' A '); The finally AContext. Connection. UnlockList;////here to unlock!!!!!! The End; end; CodePudding user response:
Weird, idtcpclient onwork not trigger events, the client want to use a thread readln constantly CodePudding user response:
reference 13 floor wylton reply: Quote: references 9 f gfuchao response: Quote: refer to 7th floor SQLDebug_Fan response: You write a response in the event of OnRead server? Procedure TForm2. IdTCPServer1Execute (AContext: TIdContext); Var Hb: TIdIOHandler; TempStr: TStrings; The begin Hb:=AContext Connection. The IOHandler; If Not Hb. InputBufferIsEmpty then The Begin nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull