server side socket program hangs

anuradha.k.r at sify.com anuradha.k.r at sify.com
Fri Sep 26 12:15:39 CEST 2003


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(socket.AF_INET,socket.SOCK_STREAM)
except socket.error:
     print 'socket not created'
try:
     s.bind((HOST,PORT))
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?




More information about the Python-list mailing list