Hello,
I am creating a client connection to a server socket that receives packets. Each time the client connects, I start a thread that reads what is available on the socket then breaks out of the thread.
I need to have that thread listen for data until the socket connection is lost. An infinite loop seems inefficient so I was wondering how this is done is the real world? How would I structure my thread run() method to sleep until new packets have arrived?
Thanks
I am creating a client connection to a server socket that receives packets. Each time the client connects, I start a thread that reads what is available on the socket then breaks out of the thread.
I need to have that thread listen for data until the socket connection is lost. An infinite loop seems inefficient so I was wondering how this is done is the real world? How would I structure my thread run() method to sleep until new packets have arrived?
Thanks