Read / Write image file
phil
phillip.watts at anvilcom.com
Tue May 3 16:17:29 EDT 2005
>
> By the way, what is 'rb' and 'wb' ?
>
Read Binary, Write Binary
In Win32 the default is text mode which
will screw up binary files
> Also, when I create a client/server sockets I do something like...
>
> SERVER
> -----------
> server.bind(('', 4321))
> (sock, addr) = server.accept()
> x = server.recv(1024)
>
> CLIENT
> ------------
> client.connect(('localhost', 4321))
> x = open("abc.txt", "rb")
> client.send(x)
> client.close()
> x.close()
>
> ...when I do this I get a constant beeping on my PC, any idea why?
> Also, on the server ...how can I set that up so I can receive a
> file/data of unknown size instead of just 1024?
>
1024 is just the buffer size. You need to recv in a loop
until the len(x) is 0. You need to do a little reading on sockets.
Beeping I've no idea. Perhaps packets not handled????
More information about the Python-list
mailing list