As others have said, TCP allows sending urgent packets, precisely for solving this problem.
At the receiver, a signal handler must be used, which will be invoked when an urgent packet is received, with SIGURG.