python - File size not updated after write()? -



python - File size not updated after write()? -

in below code trying receive file python sockets , write local file have next code

chunk=clientdtsocket.recv(1024) while chunk: print("in chunk"+str(chunk)) incomingfile.write(chunk) chunk=clientdtsocket.recv(1024)

i following

class="lang-none prettyprint-override">in chunkb'sohail khan'

but file size remains same. how can count no of bytes have recieved.

when open file set write buffer size 0:

bufsize = 0 incomingfile = open('....', 'w', bufsize)

it normal behevior, info saved file not immidiately after calling write function, afted write buffer totaly filled. if setup buffer size 0 in axample above, yoor info written immidiatel. writting info write buffer file callaed "flushing"

flushing occured when close file:

incomingfile.close()

python sockets file-io

Comments

Popular posts from this blog

formatting - SAS SQL Datepart function returning odd values -

c++ - Apple Mach-O Linker Error(Duplicate Symbols For Architecture armv7) -

php - Yii 2: Unable to find a class into the extension 'yii2-admin' -