import socket
import sys
import thread
p=1
PORT=11000
BUFSIZE=1024
def getData(cSocket ):
global stdoutlock,cSoc ketlock
while True:
cSocketlock.acq uire()
data=cSocket.re cv(BUFSIZE)
if data=='q':
data='client exited'
cSocket.close()
p=0
cSocketlock.rel ease()
stdoutlock.acqu ire()
stdout.write(da ta)
stdoutlock.rele ase()
def sendData(cSocke t):
global stdoutlock,cSoc ketlock
while True:
stdoutlock.acqu ire()
data=raw_input( '>>')
cSocketlock.acq uire_lock()
if data=='q':
stdout.write('s erver exited')
stdout.release( )
p=0
cSocket.close()
sSocket.send(da ta)
sSocketlock.rel ease()
stdout=sys.stdo ut
host=''
sSocket=socket. socket(socket.A F_INET,socket.S OCK_STREAM)
sSocket.bind((h ost,PORT,))
sSocket.listen( 1)
#sSocketlock=th read.allocate_l ock()
stdoutlock=thre ad.allocate_loc k()
print 'waiting for connection'
cSocket,addr=sS ocket.accept()
print 'connection from',addr
cSocketlock=thr ead.allocate_lo ck()
thread.start_ne w_thread(sendDa ta,(cSocket,))
thread.start_ne w_thread(getDat a,(cSocket,))
if p==0:
sSocket.close()
In the above program, why there is an unhandeled exception ???
import sys
import thread
p=1
PORT=11000
BUFSIZE=1024
def getData(cSocket ):
global stdoutlock,cSoc ketlock
while True:
cSocketlock.acq uire()
data=cSocket.re cv(BUFSIZE)
if data=='q':
data='client exited'
cSocket.close()
p=0
cSocketlock.rel ease()
stdoutlock.acqu ire()
stdout.write(da ta)
stdoutlock.rele ase()
def sendData(cSocke t):
global stdoutlock,cSoc ketlock
while True:
stdoutlock.acqu ire()
data=raw_input( '>>')
cSocketlock.acq uire_lock()
if data=='q':
stdout.write('s erver exited')
stdout.release( )
p=0
cSocket.close()
sSocket.send(da ta)
sSocketlock.rel ease()
stdout=sys.stdo ut
host=''
sSocket=socket. socket(socket.A F_INET,socket.S OCK_STREAM)
sSocket.bind((h ost,PORT,))
sSocket.listen( 1)
#sSocketlock=th read.allocate_l ock()
stdoutlock=thre ad.allocate_loc k()
print 'waiting for connection'
cSocket,addr=sS ocket.accept()
print 'connection from',addr
cSocketlock=thr ead.allocate_lo ck()
thread.start_ne w_thread(sendDa ta,(cSocket,))
thread.start_ne w_thread(getDat a,(cSocket,))
if p==0:
sSocket.close()
In the above program, why there is an unhandeled exception ???
Comment