server side socket program hangs
anuradha.k.r at sify.com
anuradha.k.r at sify.com
Mon Oct 20 00:56:41 EDT 2003
hi,
do u think there's a version problem?i am using Python 2.2 (windows
2000).is it related in any way?
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