简体   繁体   中英

Delphi indy10 sockets data exchange on multiple forms

I am using indy10 sockets, and I ran into a small snag. I have my IdTCPServer on form one and I am wanting to send data from form 2 to remote location. I would think AContext.IOHandler.WriteLn() would work but in form 2 it throws errors and Identifier not found AContext.

It was simple to send and receive text on the client side. But, I am looking for a way to send text from the server on different form from the socket. If anything I will do a messy job and put invisible memo to send to then read the memo from there and send it off.

You are on the right track - using the IOHandler object of a given TIdContext - but you are looking in the wrong place for it. From outside of the server's event handlers, you can access active TIdContext objects using the TIdTCPServer.Contexts property., which is a TThreadList of active connections. To keep track of per-client data, such as login identifiers, you can use the TIdContext.Data property, or derive a new class from TIdServerContext and then assign it to the TIdTCPServer.ContextClass property.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM