RAD Studio
ContentsIndex
PreviousUpNext
Responding to socket events
Name 
Description 
When a client socket opens a connection, the following events occur:
  • The socket is set up and initialized for event notification.
  • An OnCreateHandle event occurs after the server and server socket is created. At this point, the socket object available through the Handle property can provide information about the server or client socket that will form the other end of the connection. This is the first chance to obtain the actual port used for the connection, which may differ from the port of the listening sockets that accepted the connection.
  • The connection request is accepted by the server and completed... more 
Client and server sockets generate OnError events when they receive error messages from the connection. You can write an OnError event handler to respond to these error messages. The event handler is passed information about
  • What socket object received the error notification.
  • What the socket was trying to do when the error occurred.
  • The error code that was provided by the error message.
You can respond to the error in the event handler, and change the error code to 0 to prevent the socket from raising an exception. 
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... more 
Server socket components form two types of connections: listening connections and connections to client applications. The server socket receives events during the formation of each of these connections. 
Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!