smilesonisa...@gmail.com writes:

> Hi,
>    I am trying to write a TCP socket program in python. I am using python 2.6 
> in linux. 
>
> I referred following link:
> http://www.ibm.com/developerworks/linux/tutorials/l-pysocks/section4.html
> I am actually writing the client-side stream socket.
> I wrote a small program which creates the socket, bind to the socket, connect 
> to socket and send() close(). I see that there is no reply coming from server 
> and the TCP disconnect happens.
> import socket
>
> def tcp(host, request, port=34567):
>
> s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
>
> s.connect((host, port))
>
> s.send(request)
>
> reply = s.recv(2**14)
>
> s.close()
>
> return reply
>
> My problem is even if the request is sent the length(reply) is is 0. I tried 
> to put a timeout of 1 sec s.settimeout() call after the send call but it 
> doesnot help.
>
> I tried by commenting s.close() still it did not work.
>
> Any idea what is the problem?

Length(reply) == 0 means that the other side closed the socket without sending 
anything back.
-- 
Piet van Oostrum <p...@vanoostrum.org>
WWW: http://pietvanoostrum.com/
PGP key: [8DAE142BE17999C4]
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to