Java TCP Listener loop

ph4ut4

New Member
I've been searching for hours on google as I know this is a really simple problem I'm facing but I can't find a SIMPLE solution to my issue.I'm writing a really basic IRC client, just to re-learn the ropes of Java as its been a long time since I've done any coding and I have a project I want to do later.I'm stuck at the socket listener though, I can provide code if needed, but all I really need is a SIMPLE tutorial on how to create a loop that listens to and already created socket, and does something as soon as it receives any data. This loop should continue until the socket is closed (the user disconnects from the server)The issue with my current code is the listener seems to hang the entire program UNTIL it receives data. I've even put a while loop in a separate thread so it can hang that thread until data arrives, yet it still hangs the entire program.I don't want to be told the answer, I want to know how to find the answer. I have even looked at creating an event driven listener, but that seemed overly complex for what I need.
 
Back
Top