On_sock_data_arrival Event


Generated when at least one data byte is present in the RX buffer of the socket (i.e. for this socket the sock.rxlen>0).



See Also:



When the event handler for this event is entered the sock.num property is automatically switched to the socket for which this event was generated. Another on_sock_data_arrival event on a particular socket is never generated until the previous one is processed.

Use the sock.getdata method to extract the data from the RX buffer.

For TCP protocol (sock.protocol= 1- PL_SOCK_PROTOCOL_TCP), there is no separation into individual packets and you get all arriving data as a "stream". You don't have to process all data in the RX buffer at once. If you exit the on_sock_data_arrival event handler while there is still some unprocessed data in the RX buffer another on_sock_data_arrival event will be generated immediately.

For UDP protocol (sock.protocol= 0- PL_SOCK_PROTOCOL_UDP), the RX buffer preserves datagram boundaries. Each time you enter the on_sock_data_arrival event handler you get to process next UDP datagram. If you do not process entire datagram contents the unread portion of the datagram is discarded once you exit the event handler.

This event is not generated for a particular socket when buffer redirection is set for this socket through the sock.redir method.