tags:

views:

222

answers:

2
+1  A: 

Not my area of expertise, but I think that the second sample will open a second connection, while the first sample keeps an open handle to the same connection. So any solution which involves opening only one connection should work.

Lucero
+5  A: 

The second snippet fails because it opens two separate TCP sockets. The echo connects to www.google.com and writes the HTTP request; and then the second line opens another connection and tries to read from that socket. The second socket simply blocks because Google is waiting for the HTTP request to be sent.

John Kugelman
any idea on how to make it work on one line?
User1
John Kugelman