server side socket program hangs

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • anuradha.k.r@sify.com

    server side socket program hangs

    hi,
    i am writing a socket program in python,both client side and server
    side.I've written the client side which is working perfectly
    fine(checked it against server program written in C).but as for my
    server program written in python it simply hangs.it does not show any
    error also.I've tried sample programs available .I don understand what
    the reason is as i am quite new to it.
    here is teh server side program:

    ///////////////////////
    from socket import *
    import socket
    import sys

    HOST = '' #any address
    PORT = htons(9999) #same port address as client

    try:
    s = socket.socket(s ocket.AF_INET,s ocket.SOCK_STRE AM)
    except socket.error:
    print 'socket not created'
    try:
    s.bind((HOST,PO RT))
    except socket.error:
    print 'error in bind'
    try:
    s.listen(5)
    except socket.error:
    print 'error in listen'
    conn, addr = s.accept()
    print 'Connected by', addr
    while 1:
    data = conn.recv(1024)
    if not data: break
    conn.send(data)
    conn.close()

    can someone tell me what the problem is?
  • Anthony McDonald

    #2
    Re: server side socket program hangs

    <anuradha.k.r@s ify.com> wrote in message
    news:57efaf35.0 309260215.5ddd5 734@posting.goo gle.com...[color=blue]
    > hi,
    > i am writing a socket program in python,both client side and server
    > side.I've written the client side which is working perfectly
    > fine(checked it against server program written in C).but as for my
    > server program written in python it simply hangs.it does not show any
    > error also.I've tried sample programs available .I don understand what
    > the reason is as i am quite new to it.
    > here is teh server side program:
    >
    > ///////////////////////
    > from socket import *
    > import socket
    > import sys
    >
    > HOST = '' #any address
    > PORT = htons(9999) #same port address as client
    >[/color]
    <snip code>[color=blue]
    >
    > can someone tell me what the problem is?[/color]

    Your applying a function designed to simplyfy transfering IP addresses to a
    literal value you want to use for your port. The following should show the
    effect thats now happening.

    PythonWin 2.3.1 (#47, Sep 23 2003, 23:47:32) [MSC v.1200 32 bit (Intel)] on
    win32.
    Portions Copyright 1994-2001 Mark Hammond (mhammond@skipp inet.com.au) - see
    'Help/About PythonWin' for further copyright information.[color=blue][color=green][color=darkred]
    >>> import socket
    >>> socket.htons(99 99)[/color][/color][/color]
    3879[color=blue][color=green][color=darkred]
    >>>[/color][/color][/color]

    --
    Anthony McDonald

    This email address is protected by SpamBayes



    Comment

    • anuradha.k.r@sify.com

      #3
      Re: server side socket program hangs

      hi,
      was stuck with another work.now bac to python program.
      i tried out using
      PORT = socket.htons(99 99)

      it still doesn't work.here is the code.it still hangs.can some one
      tell me what could be te problem?

      #from socket import *
      import socket
      import sys

      HOST = '' #any address
      PORT = socket.htons(92 22) #same port address as client

      class Sock:
      def __init__ (self,parent):
      try:
      self.s = socket(AF_INET, SOCK_STREAM)
      except socket.error:
      print 'socket not created'
      try:
      self.s.bind((HO ST,PORT))
      except self.error:
      print 'error in bind'
      try:
      self.s.listen(5 )
      except self.error:
      print 'error in listen'
      conn, addr = self.s.accept()
      # print 'Connected by',`addr`
      while 1:
      data = conn.recv(1024)
      if not data: break
      conn.send(data)
      conn.close()

      thanx,
      AKR.



      "Anthony McDonald" <tonym1972/at/club-internet/in/fr> wrote in message news:<3f74571f$ 0$20952$7a628cd 7@news.club-internet.fr>...[color=blue]
      > <anuradha.k.r@s ify.com> wrote in message
      > news:57efaf35.0 309260215.5ddd5 734@posting.goo gle.com...[color=green]
      > > hi,
      > > i am writing a socket program in python,both client side and server
      > > side.I've written the client side which is working perfectly
      > > fine(checked it against server program written in C).but as for my
      > > server program written in python it simply hangs.it does not show any
      > > error also.I've tried sample programs available .I don understand what
      > > the reason is as i am quite new to it.
      > > here is teh server side program:
      > >
      > > ///////////////////////
      > > from socket import *
      > > import socket
      > > import sys
      > >
      > > HOST = '' #any address
      > > PORT = htons(9999) #same port address as client
      > >[/color]
      > <snip code>[color=green]
      > >
      > > can someone tell me what the problem is?[/color]
      >
      > Your applying a function designed to simplyfy transfering IP addresses to a
      > literal value you want to use for your port. The following should show the
      > effect thats now happening.
      >
      > PythonWin 2.3.1 (#47, Sep 23 2003, 23:47:32) [MSC v.1200 32 bit (Intel)] on
      > win32.
      > Portions Copyright 1994-2001 Mark Hammond (mhammond@skipp inet.com.au) - see
      > 'Help/About PythonWin' for further copyright information.[color=green][color=darkred]
      > >>> import socket
      > >>> socket.htons(99 99)[/color][/color]
      > 3879[color=green][color=darkred]
      > >>>[/color][/color][/color]

      Comment

      • Anthony McDonald

        #4
        Re: server side socket program hangs

        <anuradha.k.r@s ify.com> wrote in message
        news:57efaf35.0 310092102.1231b 120@posting.goo gle.com...[color=blue]
        > hi,
        > was stuck with another work.now bac to python program.
        > i tried out using
        > PORT = socket.htons(99 99)
        >
        > it still doesn't work.here is the code.it still hangs.can some one
        > tell me what could be te problem?
        >
        > #from socket import *
        > import socket
        > import sys
        >
        > HOST = '' #any address
        > PORT = socket.htons(92 22) #same port address as client
        >
        > class Sock:
        > def __init__ (self,parent):
        > try:
        > self.s = socket(AF_INET, SOCK_STREAM)
        > except socket.error:
        > print 'socket not created'
        > try:
        > self.s.bind((HO ST,PORT))
        > except self.error:
        > print 'error in bind'
        > try:
        > self.s.listen(5 )
        > except self.error:
        > print 'error in listen'
        > conn, addr = self.s.accept()
        > # print 'Connected by',`addr`
        > while 1:
        > data = conn.recv(1024)
        > if not data: break
        > conn.send(data)
        > conn.close()
        >
        > thanx,
        > AKR.
        >[/color]
        Sorry for my brief answer last time, but I had hoped the code fragment I
        posted would explain what was happening with your code.

        Your code is almost a verbatum copy of the Python example, except you've
        chosen to massage the port value using the HTONS function. So for most
        architectures the port value 9999 or 9222 would be changed to somewhere in
        the 3xxx port range. Any client trying to connect on those ports will fail.
        Hence you noted success on a C server which isn't using that function, but
        failure on your Python server which is. The solution is to just assign the
        port value you want unchanged.

        --
        Anthony McDonald

        This email address is protected by SpamBayes



        Comment

        • anuradha.k.r@sify.com

          #5
          Re: server side socket program hangs

          hi,
          My one problem is solved,python server no more hangs,but my main
          purpose still remains unsolved,my client is not able to establish
          connection.my client is a C program running on a windows machine.On
          running the python program,in the python shell i get this way[color=blue][color=green][color=darkred]
          >>>[/color][/color][/color]
          (cursor)

          i assumed my server is waiting for a connection,but my client did not
          connect,it failed.
          I tried debugging the python program using the step by step debug
          control.it moves till def __init__(Self,p arent):
          and stops(seems to be waiting).It does not move to the next line.
          Can you tell me what is happening? and what is the problem with my
          server program?Sorry for the trouble,
          thanx
          AKR.









          "Anthony McDonald" <tonym1972/at/club-internet/in/fr> wrote in message news:<3f8670c7$ 0$12567$7a628cd 7@news.club-internet.fr>...[color=blue]
          > <anuradha.k.r@s ify.com> wrote in message
          > news:57efaf35.0 310092102.1231b 120@posting.goo gle.com...[color=green]
          > > hi,
          > > was stuck with another work.now bac to python program.
          > > i tried out using
          > > PORT = socket.htons(99 99)
          > >
          > > it still doesn't work.here is the code.it still hangs.can some one
          > > tell me what could be te problem?
          > >
          > > #from socket import *
          > > import socket
          > > import sys
          > >
          > > HOST = '' #any address
          > > PORT = socket.htons(92 22) #same port address as client
          > >
          > > class Sock:
          > > def __init__ (self,parent):
          > > try:
          > > self.s = socket(AF_INET, SOCK_STREAM)
          > > except socket.error:
          > > print 'socket not created'
          > > try:
          > > self.s.bind((HO ST,PORT))
          > > except self.error:
          > > print 'error in bind'
          > > try:
          > > self.s.listen(5 )
          > > except self.error:
          > > print 'error in listen'
          > > conn, addr = self.s.accept()
          > > # print 'Connected by',`addr`
          > > while 1:
          > > data = conn.recv(1024)
          > > if not data: break
          > > conn.send(data)
          > > conn.close()
          > >
          > > thanx,
          > > AKR.
          > >[/color]
          > Sorry for my brief answer last time, but I had hoped the code fragment I
          > posted would explain what was happening with your code.
          >
          > Your code is almost a verbatum copy of the Python example, except you've
          > chosen to massage the port value using the HTONS function. So for most
          > architectures the port value 9999 or 9222 would be changed to somewhere in
          > the 3xxx port range. Any client trying to connect on those ports will fail.
          > Hence you noted success on a C server which isn't using that function, but
          > failure on your Python server which is. The solution is to just assign the
          > port value you want unchanged.[/color]

          Comment

          • anuradha.k.r@sify.com

            #6
            Re: server side socket program hangs

            hi,
            i've posted my doubt on my server program written in python.i am not
            able to communicate with any client.My server program does not even
            create a socket.can someone tell me what the problem is?
            thanx,
            AKR


            anuradha.k.r@si fy.com wrote in message news:<57efaf35. 0310132112.6ecd 9840@posting.go ogle.com>...[color=blue]
            > hi,
            > My one problem is solved,python server no more hangs,but my main
            > purpose still remains unsolved,my client is not able to establish
            > connection.my client is a C program running on a windows machine.On
            > running the python program,in the python shell i get this way[color=green][color=darkred]
            > >>>[/color][/color]
            > (cursor)
            >
            > i assumed my server is waiting for a connection,but my client did not
            > connect,it failed.
            > I tried debugging the python program using the step by step debug
            > control.it moves till def __init__(Self,p arent):
            > and stops(seems to be waiting).It does not move to the next line.
            > Can you tell me what is happening? and what is the problem with my
            > server program?Sorry for the trouble,
            > thanx
            > AKR.
            >
            >
            >
            >
            >
            >
            >
            >
            >
            > "Anthony McDonald" <tonym1972/at/club-internet/in/fr> wrote in message news:<3f8670c7$ 0$12567$7a628cd 7@news.club-internet.fr>...[color=green]
            > > <anuradha.k.r@s ify.com> wrote in message
            > > news:57efaf35.0 310092102.1231b 120@posting.goo gle.com...[color=darkred]
            > > > hi,
            > > > was stuck with another work.now bac to python program.
            > > > i tried out using
            > > > PORT = socket.htons(99 99)
            > > >
            > > > it still doesn't work.here is the code.it still hangs.can some one
            > > > tell me what could be te problem?
            > > >
            > > > #from socket import *
            > > > import socket
            > > > import sys
            > > >
            > > > HOST = '' #any address
            > > > PORT = socket.htons(92 22) #same port address as client
            > > >
            > > > class Sock:
            > > > def __init__ (self,parent):
            > > > try:
            > > > self.s = socket(AF_INET, SOCK_STREAM)
            > > > except socket.error:
            > > > print 'socket not created'
            > > > try:
            > > > self.s.bind((HO ST,PORT))
            > > > except self.error:
            > > > print 'error in bind'
            > > > try:
            > > > self.s.listen(5 )
            > > > except self.error:
            > > > print 'error in listen'
            > > > conn, addr = self.s.accept()
            > > > # print 'Connected by',`addr`
            > > > while 1:
            > > > data = conn.recv(1024)
            > > > if not data: break
            > > > conn.send(data)
            > > > conn.close()
            > > >
            > > > thanx,
            > > > AKR.
            > > >[/color]
            > > Sorry for my brief answer last time, but I had hoped the code fragment I
            > > posted would explain what was happening with your code.
            > >
            > > Your code is almost a verbatum copy of the Python example, except you've
            > > chosen to massage the port value using the HTONS function. So for most
            > > architectures the port value 9999 or 9222 would be changed to somewhere in
            > > the 3xxx port range. Any client trying to connect on those ports will fail.
            > > Hence you noted success on a C server which isn't using that function, but
            > > failure on your Python server which is. The solution is to just assign the
            > > port value you want unchanged.[/color][/color]

            Comment

            • anuradha.k.r@sify.com

              #7
              Re: server side socket program hangs

              hi,
              my initial program was to take host value as ''(INADDR_ANY)
              only.during my trial and error only i started using
              gethostname.how ever 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.


              Jørgen Cederberg <jorgencederber g@hotmail.com> wrote in message news:<9sujb.997 $Z54.969@news.g et2net.dk>...[color=blue]
              > anuradha.k.r@si fy.com wrote:[color=green]
              > > 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.however
              > > 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[/color]
              >
              > Hi ...
              >
              > the program actually works - but there is a quirk, look below for details.
              >[color=green]
              > >
              > > ////////////////
              > > 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((gethost name(),port))[/color]
              >
              > You are binding the socket to the hostname of your computer, instead of
              > ''. 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
              >
              >[color=green]
              > > 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.[/color]
              >
              >
              > Hope this helps
              > Jorgen[/color]

              Comment

              • Jørgen Cederberg

                #8
                Re: server side socket program hangs

                anuradha.k.r@si fy.com wrote:[color=blue]
                > hi,
                > my initial program was to take host value as ''(INADDR_ANY)
                > only.during my trial and error only i started using
                > gethostname.how ever 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.[/color]

                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

                [color=blue]
                >
                >
                > Jørgen Cederberg <jorgencederber g@hotmail.com> wrote in message news:<9sujb.997 $Z54.969@news.g et2net.dk>...[color=green]
                >> anuradha.k.r@si fy.com wrote:[color=darkred]
                >> > 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.however
                >> > 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[/color]
                >>
                >> Hi ...
                >>
                >> the program actually works - but there is a quirk, look below for details.
                >> [color=darkred]
                >> >
                >> > ////////////////
                >> > 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((gethost name(),port))[/color]
                >>
                >> You are binding the socket to the hostname of your computer, instead of
                >> ''. 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
                >>
                >> [color=darkred]
                >> > 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.[/color]
                >>
                >>
                >> Hope this helps
                >> Jorgen[/color][/color]

                Comment

                • anuradha.k.r@sify.com

                  #9
                  Re: server side socket program hangs

                  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()(functi on 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 <jorgencederber g@hotmail.com> wrote in message news:<dKMjb.833 $vv7.273@news.g et2net.dk>...[color=blue]
                  > anuradha.k.r@si fy.com wrote:[color=green]
                  > > hi,
                  > > my initial program was to take host value as ''(INADDR ANY)
                  > > only.during my trial and error only i started using
                  > > gethostname.how ever 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.[/color]
                  >
                  > 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
                  >
                  >[color=green]
                  > >
                  > >
                  > > J rgen Cederberg <jorgencederber g@hotmail.com> wrote in message news:[/color]
                  > <9sujb.997$Z54. 969@news.get2ne t.dk>...[color=green][color=darkred]
                  > >> anuradha.k.r@si fy.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[/color][/color]
                  > er[color=green][color=darkred]
                  > >> > 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[/color][/color]
                  > to[color=green][color=darkred]
                  > >> > 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[/color][/color]
                  > ils.[color=green][color=darkred]
                  > >>
                  > >> >
                  > >> > ////////////////
                  > >> > 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((gethost name(),port))
                  > >>
                  > >> You are binding the socket to the hostname of your computer, instead o[/color][/color]
                  > f[color=green][color=darkred]
                  > >> ''. Thus it will only accept connections specific to the hostname and[/color][/color]
                  >[color=green][color=darkred]
                  > >> 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[/color][/color]
                  >[color=green][color=darkred]
                  > >> > give me few links where i can find a solution,thanx.
                  > >> > AKR.
                  > >>
                  > >>
                  > >> Hope this helps
                  > >> Jorgen[/color][/color][/color]

                  Comment

                  • anuradha.k.r@sify.com

                    #10
                    Re: server side socket program hangs

                    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 <jorgencederber g@hotmail.com> wrote in message news:<dKMjb.833 $vv7.273@news.g et2net.dk>...[color=blue]
                    > anuradha.k.r@si fy.com wrote:[color=green]
                    > > hi,
                    > > my initial program was to take host value as ''(INADDR ANY)
                    > > only.during my trial and error only i started using
                    > > gethostname.how ever 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.[/color]
                    >
                    > 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
                    >
                    >[color=green]
                    > >
                    > >
                    > > J rgen Cederberg <jorgencederber g@hotmail.com> wrote in message news:[/color]
                    > <9sujb.997$Z54. 969@news.get2ne t.dk>...[color=green][color=darkred]
                    > >> anuradha.k.r@si fy.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[/color][/color]
                    > er[color=green][color=darkred]
                    > >> > 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[/color][/color]
                    > to[color=green][color=darkred]
                    > >> > 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[/color][/color]
                    > ils.[color=green][color=darkred]
                    > >>
                    > >> >
                    > >> > ////////////////
                    > >> > 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((gethost name(),port))
                    > >>
                    > >> You are binding the socket to the hostname of your computer, instead o[/color][/color]
                    > f[color=green][color=darkred]
                    > >> ''. Thus it will only accept connections specific to the hostname and[/color][/color]
                    >[color=green][color=darkred]
                    > >> 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[/color][/color]
                    >[color=green][color=darkred]
                    > >> > give me few links where i can find a solution,thanx.
                    > >> > AKR.
                    > >>
                    > >>
                    > >> Hope this helps
                    > >> Jorgen[/color][/color][/color]

                    Comment

                    • Jørgen Cederberg

                      #11
                      Re: server side socket program hangs

                      anuradha.k.r@si fy.com wrote:[color=blue]
                      > hi,
                      > do u think there's a version problem?i am using Python 2.2 (windows
                      > 2000).is it related in any way?[/color]

                      I'm also using Python 2.2 on a W2K machine. Sorry, I have no clue how to
                      help you.

                      Sorry
                      Jorgen
                      [color=blue]
                      > thanx,AKR.
                      >[/color]
                      <snipped>

                      Comment

                      • anuradha.k.r@sify.com

                        #12
                        Re: server side socket program hangs

                        hi,
                        My problem is solved finally.......:-))))))))))
                        it was the problem with port address.my server side does not accept
                        little endian,i need to convert it to big endian form...like if am
                        using the port address 9020 on the client side ,the corresponding big
                        endian wud be 15395 ( to be used in my server).so that was wat was
                        creating so much trouble..
                        neways thanx a lot for all the help.
                        AKR.


                        Jørgen Cederberg <jorgencederber g@hotmail.com> wrote in message news:<nzLkb.43$ pI2.20@news.get 2net.dk>...[color=blue]
                        > anuradha.k.r@si fy.com wrote:[color=green]
                        > > hi,
                        > > do u think there's a version problem?i am using Python 2.2 (windows
                        > > 2000).is it related in any way?[/color]
                        >
                        > I'm also using Python 2.2 on a W2K machine. Sorry, I have no clue how to
                        > help you.
                        >
                        > Sorry
                        > Jorgen
                        >[color=green]
                        > > thanx,AKR.
                        > >[/color]
                        > <snipped>[/color]

                        Comment

                        Working...