Responding to Socket Events

From RAD Studio
Jump to: navigation, search

Go Up to Working with Sockets Index


When writing applications that use sockets, you can write or read to the socket anywhere in the program. You can write to the socket using the SendBuf, SendStream, or Sendln methods in your program after the socket has been opened. You can read from the socket using the similarly-named methods ReceiveBuf and Receiveln. The OnSend and OnReceive events are triggered every time something is written or read from the socket. They can be used for filtering. Every time you read or write, a read or write event is triggered.

Both client sockets and server sockets generate Error Events when they receive error messages from the connection.

Socket components also receive two events in the course of opening and completing a connection. If your application needs to influence how the opening of the socket proceeds, you must use the SendBuf and ReceiveBuf methods to respond to these Client Events or Server Events.

See Also