sockets and data??
akhar
akhar at videotron.ca
Tue Apr 24 01:20:06 EDT 2001
I have a python program that send text to a socket and another, the server
program responds with the string and a hello. now I try to transmit a file,
and exeptions are raised?? I am actually trying to stream audio but the file
won't read? what do I do to read while receiving data?
many thanks in advance
Stephane
here is the client and the server.
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
client
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
from Tkinter import *
from tkSnack import *
from socket import *
import time
root = Tkinter.Tk()
initializeSnack(root)
s1 = Sound(load='c:/windows/media/tada.wav')
s2 = Sound(load='c:/windows/media/tada.wav')
s= socket(AF_INET, SOCK_STREAM)
s.connect(('localhost', 8472))
#tm = s.recv(1024)
r = "the time is " #+ tm
rm = "\n sending sound" + "\n" + r
sss=open("c:/windows/media/tada.wav")
print rm
#s.send(s1.read('c:/windows/media/tada.wav'))
#s.send(sss.read())
ssss= sss.read()
print "file read \n"
s.send(ssss)
print "file sent \n"
s.close()
print "socket closed\n"
#s2.play()
sss.close()
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
the server
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
from Tkinter import *
from tkSnack import *
from socket import *
import time
root = Tkinter.Tk()
initializeSnack(root)
s1 = Sound()
s = socket(AF_INET, SOCK_STREAM)
s.bind(('localhost', 8472))
s.listen(5)
while 1:
client,addr = s.accept()
print "Got a connection from ",addr
print "time sent"
#client.send(time.ctime(time.time()))
print "time sent"
#client.close()
#client,addr = s.accept()
rx = client.recv(1024)
s1.read(rx)
s1.play()
client.close()
print rx
More information about the Python-list
mailing list