Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I have a simply Http Server written by Python's BaseHTTPRequestHandler. With a client written by Java in Android with HttpClient. And I want to push data from python server to client java: So I try to make a while True loop at server,

A few piece of server's code:
def do_POST(self):
    # receive POST data from client
    # ...
    # Then I want to keep alive this connection
    while True:
        # wait for a message, then reply to client

And HttpClient and MultipartEntity for java Client:
    protected String doInBackground() {
        HttpClient httpClient = new DefaultHttpClient();
        MultipartEntity entity = new ....
        // Get Http Response
        HttpResponse response = httpClient.execute(entity); // Here I've been blocked
     }

I want to receive server's response contiguously after httpClient.execute(). But I am blocked at the last source of client because the While True loop at server. I guess httpClient.execute() is waiting for the http socket closing? Can you please help me for how to handle this situation? Thanks very much. I have searched the push technology and seems long pulling is another way to push. But I think push is more better solution for my situation. Because I'm not simular to how to asking question in the web. Please forgive my mistakes in typesetting. Thanks very much.

attached dummy text for submitting problems: When you asking questions, using some more words to describe your problem will always help. If there are really nothing more to say, just copy some random paragraph from internet, but make sure you mark them as dummy text so that people won't pay attention on them.

Sincerley

share
add comment

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.