server side socket program hangs
anuradha.k.r at sify.com
anuradha.k.r at sify.com
Wed Oct 15 02:25:58 EDT 2003
More information about the Python-list mailing list
Wed Oct 15 02:25:58 EDT 2003
- Previous message (by thread): server side socket program hangs
- Next message (by thread): server side socket program hangs
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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 at sify.com wrote in message news:<57efaf35.0310132112.6ecd9840 at posting.google.com>... > 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 > >>> > (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,parent): > 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$7a628cd7 at news.club-internet.fr>... > > <anuradha.k.r at sify.com> wrote in message > > news:57efaf35.0310092102.1231b120 at posting.google.com... > > > hi, > > > was stuck with another work.now bac to python program. > > > i tried out using > > > PORT = socket.htons(9999) > > > > > > 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(9222) #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((HOST,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. > > > > > 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.
- Previous message (by thread): server side socket program hangs
- Next message (by thread): server side socket program hangs
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list