Hmm... sounds like it is only sending after it has filled up a buffer. Any chance you are using a buffered stream reader/writer of some sort? If so, look for a flush operation you can call.
(Or maybe the buffering is happening at the TCP level, underneath your Java or Python code. Not sure. It's been a while since I've done any network programming...)