filesize() returns 0


Posted on 16th Feb 2014 07:03 pm by admin

I have a socket program that runs in an infinite loop, listening for connections, in this socket I have a method, that is supposed to open a file and write to the file, but I am having issues. Each call to the socket happens about once every 1.5 seconds, and then, it writes to the socket, but for some reason, filesize is always returning "0" even when the file is 1.5kb in size.

I use a string var to to defiine the file and it's positions:
var $file = 'C:php_filesPhediatest.flv';

Why is it returning 0? It writes to the file fine, so why cant it get the correct size?

this function is ran about every 1.5 seconds, it is supposed to append the new data to the current file:
function dataRecieved($allclient, $socket, $buf) {
echo filesize($this->file)."nn";
$this->handle = fopen($this->file, "a+b");
if(filesize($this->file) < 1){
$buf = "FLV".pack('C', 1).pack('C', 1).pack('N', 9).pack('N', 9).$buf;
}
if(fwrite($this->handle, $buf)){
echo "Wrote to filen";
echo $buf;
}
fclose($this->handle);
}

No comments posted yet

Your Answer:

Login to answer
258 Like 35 Dislike
Previous forums Next forums
Other forums

php sessions,logouts & the bloomin back button!
Hi All,

I've got a cms that members can log into. When they logout, the session is destroyed,

PHP Include w/If IE Condition Statement?
I was having a problem with Internet Exploder (big surprise, right?) displaying my drop down menus i

data type in column definition
Hi,
I create a table with column called "Direction of Travel code ".
The travel codes in t

How a counter of users ? such as ---> (231 Viewing)
I want to count how many users are actually viewing the page, How is that possible?
Thank you guy

ctype() validation - allowing illegal characters
Hello,
I use ctype() to filter and validate a user form. However, I am trying to allow certain c

Sales orders ans reservations not taken into account on MPS / MRP
Hello,

I am implementing the MPS / MRP and I have the following problem:

I ha

How to restrict the display of report variants
Hello All,

I want t know how to restrict the display of report variants.
I mean, whe

How to use Substr
I want to check for the word CATEGORY: inside a string which can be CATEGORY: ITEM
and remove the

please fix the error
What is the error in the below code ???
Line number On/Off | Expand/Contract <?php

Keeping data in form
How can I keep whatever I write in the form?

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash