Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #62578

python socket query

Newsgroups comp.lang.python
Date 2013-12-22 19:05 -0800
Message-ID <3cea84e7-bfd5-4feb-b786-96a3501ffcf4@googlegroups.com> (permalink)
Subject python socket query
From smilesonisamal@gmail.com

Show all headers | View raw


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?

Regards

Pradeep

Back to comp.lang.python | Previous | NextNext in thread | Find similar | Unroll thread


Thread

python socket query smilesonisamal@gmail.com - 2013-12-22 19:05 -0800
  Re: python socket query Chris Angelico <rosuav@gmail.com> - 2013-12-23 14:19 +1100
    Re: python socket query smilesonisamal@gmail.com - 2013-12-23 19:33 -0800
      Re: python socket query Chris Angelico <rosuav@gmail.com> - 2013-12-24 14:54 +1100
  Re: python socket query Piet van Oostrum <piet@vanoostrum.org> - 2013-12-23 14:23 +0100

csiph-web