Newsgroups : Borland : borland.public.delphi.internet.winsock : 2007 Sep : Re: Socket vs IOHandler
| Subject: | Re: Socket vs IOHandler |
| Posted by: | "Remy Lebeau (TeamB)" (no.spam@no.spam.com) |
| Date: | Tue, 11 Sep 2007 10:46:52 |
"Sotiris Karanasios" <karanaso@gmail.com> wrote in message
news:46e66ee0@newsgroups.borland.com...
> Could anyone please explain the difference between socket and IOhandler ?
The Socket property is only valid when the IOHandler property points to a
TIdIOHandlerSocket-derived object. In that case, both properties will point
to the same object. If the IOHandler property does not point to a
TIdIOHandlerSocket, then the Socket property will be nil.
> Is it better to use TCPClient.Socket.WriteLn, ReadLn or
> TCPClient.IOHandler.WriteLN/ReadLn
The default IOHandler that Indy creates automatically is a
TIdIOHandlerSocket-derived object, so the Socket property will not be nil.
However, Indy does have other TIOHandler classes that are not derived from
TIdIOHandlerSocket, and you are free to write your own as well. So unless
you are doing something that specifically requires a valid
TIdIOHandlerSocket object to be present, then you should use the IOHandler
property instead of the Socket property so that you have more flexibility.
> Is it better to use TCPServer.Socket.WriteLn, ReadLn or
> TCPServer.IOHandler.WriteLN/ReadLn
You can't use a server-side IOHandler property for reading/writing (it is
meant for something else), and there is no Socket property at all. When
reading/writing inside the server, you need to access the IOHandler/Socket
of the particular client connection that you are interested in.
Gambit
none