server side socket program hangs

anuradha.k.r at sify.com anuradha.k.r at sify.com
Mon Oct 20 00:39:51 EDT 2003


hi,
   Well i dono wat more to say.My client side is working properly ,the
error i get in the client side is connection refused.my client
responds to other server programs.
In my earlier postings i'd mentioned that while debugging i am not
able to understand what is happening at the def accept()(function call
in socket.py).
I use debugger control to debug,my program stays still at
accept().First i thought its waiting for a connection,but then my
client failed,morover my server is not ending.(it is not because of
the infinite while loop,i 've checked without the while loop).
When i try to close this program alone all the python applications
close.i guess itz hanging only.I don think it is system dependent.
Neways i tried from other machines ,the program still hangs.I am sorry
,but this is wat all i can say.
Do tell if there are any kind of problem related.
thanx,
AKR.


Jørgen Cederberg <jorgencederberg at hotmail.com> wrote in message news:<dKMjb.833$vv7.273 at news.get2net.dk>...
> anuradha.k.r at sify.com wrote:
> > hi,
> >    my initial program was to take host value as ''(INADDR ANY)
> > only.during my trial and error only i started using
> > gethostname.however as of now i am running my client (C program) also
> > from the same machine only.so it should not make any difference.
> > I've reverted bac to host ''.my program still hangs.i 'v e tried
> > changing the port address,but doesn't work.pls help
> > thanx,
> > AKR.
> 
> Hi
> 
> this is pretty odd. As mentioned in the previous mail, the program works 
> 
> with my client program (written in Python by the way).
> 
> You keep saying that the programs 'hang', what do mean by that?  I've 
> tried the program and all I can say is that it works. Are you sure that 
> your client works correctly?
> 
> Regards
> Jorgen
> 
> 
> > 
> > 
> > J rgen Cederberg <jorgencederberg at hotmail.com> wrote in message news:
>  <9sujb.997$Z54.969 at news.get2net.dk>...
> >> anuradha.k.r at sify.com wrote:
> >> > hi,
> >> >   i guess no one is ready to help.neways,my problem is getting
> >> > solved.I 've slightly modified program (one of the samples found in
> >> > the net),now program creates socket,gives bind ,listen success.howev
>  er
> >> > when i debug at accept it goes to the socket.py,at the accept()
> >> > function definition.and one more step ahead and it hangs.i dono how 
>  to
> >> > debug here(inside socket.py).
> >> > 
> >> > here is how the code looks like
> >> 
> >> Hi ...
> >> 
> >> the program actually works - but there is a quirk, look below for deta
>  ils.
> >> 
> >> > 
> >> > ////////////////
> >> > from socket import *
> >> > import sys
> >> > 
> >> > try:
> >> >     s= socket(AF INET,SOCK STREAM)
> >> >     print 'socket created'
> >> > except error:
> >> >     print 'socket not created'
> >> > host = ''
> >> > port = 9323
> >> > try:
> >> >     s.bind((gethostname(),port))
> >> 
> >> You are binding the socket to the hostname of your computer, instead o
>  f 
> >> ''.  Thus it will only accept connections specific to the hostname and
>   
> >> therefor fail if you try to connect to localhost or 127.0.0.1
> >> 
> >> 
> >> >     print 'bind success'
> >> > except error:
> >> >     print 'bind'
> >> > try:
> >> >     s.listen(1)
> >> >     print 'listen success'
> >> > except error:
> >> >     print 'listen'
> >> > 
> >> > conn,addr = s.accept()
> >> > print 'client is at ', addr
> >> > data = conn.recv(1024)
> >> > conn.send(data)
> >> > conn.close()
> >> > ////////////////////////
> >> >     but i have a feeling that teher's some problem with the port or
> >> > some problem in the program that it hangs.can anyone help?or atleast
>  
> >> > give me few links where i can find a solution,thanx.
> >> > AKR.
> >> 
> >> 
> >> Hope this helps
> >> Jorgen




More information about the Python-list mailing list