Mantis - Quercus
Viewing Issue Advanced Details
2060 minor always 10-10-07 17:53 10-17-07 13:26
koreth  
mo  
normal  
closed 3.1.3  
fixed  
none    
none 3.1.4  
0002060: fseek() not supported on a socket stream
PHP's fseek() is supposed to be able to discard data on a socket. Test case part 1, run on command line to set up a listen socket that will spew out some data when you connect to it:

$ echo "1234567890" | nc -l -p 8000

Test case part 2:

<?php
$sock = fsockopen("127.0.0.1", "8000");
fseek($sock, 5, SEEK_CUR);
print fgets($sock);

Vanilla PHP prints "67890". Quercus throws an exception:

java.lang.UnsupportedOperationException: com.caucho.vfs.SocketStream

Notes
(0002340)
mo   
10-12-07 12:52   
This test case generates the following stack trace:

java.lang.UnsupportedOperationException: com.caucho.vfs.SocketStream
        at com.caucho.vfs.StreamImpl.seekStart(StreamImpl.java:232)
        at com.caucho.vfs.ReadStream.setPosition(ReadStream.java:232)
        at com.caucho.quercus.lib.file.AbstractBinaryInputOutput.setPosition(AbstractBinaryInputOutput.java:259)
        at com.caucho.quercus.lib.file.AbstractBinaryInputOutput.seek(AbstractBinaryInputOutput.java:283)
        at com.caucho.quercus.lib.file.FileModule.fseek(FileModule.java:1593)


Attached is php/1m0p.qa, a rough draft regression test for this issue.
(0002353)
mo   
10-16-07 17:54   
This specific issue is now fixed.

php/1m0p.qa

Still, a couple of edge cases related to fread and ftell
on sockets remain.
(0002355)
mo   
10-17-07 13:26   
Added php/1m0q.qa, fseek now skipps over buffered bytes
when doing a seek forward.