php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #36354 Available data is not fread()
Submitted: 2006-02-10 15:24 UTC Modified: 2006-07-27 02:05 UTC
Votes:13
Avg. Score:4.5 ± 0.7
Reproduced:9 of 9 (100.0%)
Same Version:5 (55.6%)
Same OS:5 (55.6%)
From: psychi at freakmail dot de Assigned:
Status: Not a bug Package: Sockets related
PHP Version: 5.1.2 OS: Linux 2.6.14.5
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: psychi at freakmail dot de
New email:
PHP Version: OS:

 

 [2006-02-10 15:24 UTC] psychi at freakmail dot de
Description:
------------
Hello.

I tried to write a small icq client and connected to the icq server, received the hello packet (10 bytes, as you can see in the example) and sent a packet to the icq server (23 bytes) back. The problem is that the next call of socket_read() returns "unable to read from socket [104]: Connection reset by peer". This message generally is ok, because icq closes the connection - but there should be still waiting data for me (see Commview Log).

Where did "Paket #3" go? I can't read it with PHP, but i don't know why - but it should by somewhere... in my opinion. Tried this also with PHP 5.0.5 with same result... hope this is enough information.

- Thanks -

Commview Log (produced by given code)

Paket #1
0x0000   2A 01 B5 D2 00 04 00 00-00 01                     *.??......

Paket #2
0x0000   2A 01 00 02 00 11 00 00-00 01 00 01 00 09 01 01   *...............
0x0010   01 01 01 01 01 01 01                              .......

Paket #3
0x0000   2A 04 B5 D3 00 3A 00 01-00 09 01 01 01 01 01 01   *.??.:..........
0x0010   01 01 01 00 04 00 23 68-74 74 70 3A 2F 2F 77 77   ......#http://ww
0x0020   77 2E 61 6F 6C 2E 63 6F-6D 3F 63 63 6F 64 65 3D   w.aol.com?ccode=
0x0030   75 73 26 6C 61 6E 67 3D-65 6E 00 08 00 02 00 04   us&lang=en......

Reproduce code:
---------------
<?PHP

  socket_clear_error();
  $connection=socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
  socket_connect($connection, gethostbyname("login.icq.com"), 5190);
  $socket_data=socket_read($connection, 10, PHP_BINARY_READ);
  echo "-> ".strlen($socket_data)."<br>"; flush();
  socket_write($connection, "\x2A\x01\x00\x02\x00\x11\x00\x00\x00\x01\x00\x01\x00\x09\x01\x01\x01\x01\x01\x01\x01\x01\x01");
  $socket_data=socket_read($connection, 1, PHP_BINARY_READ);
  echo "-> ".strlen($socket_data)."<br>"; flush();

?>

Expected result:
----------------
-> 10

-> 1

Actual result:
--------------
-> 10

Warning: socket_read() [function.socket-read]: unable to read from socket [104]: Connection reset by peer in /home/html/icq.php5 on line 11
-> 0

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-02-23 01:52 UTC] martin dot fox at gmx dot com
I achieved the same problem with the same version and the same OS and don't know why this happens, but I think some time ago it worked for me! But I can't remember what I've changed that it does not work now. I really would appreciate a solution for that, the acceptance as bug or some official reaction.
 [2006-02-27 02:48 UTC] reply at here dot org
The same problem with other code, used fsockopen:

<?PHP

  $connection=fsockopen("login.icq.com", 5190);
  $socket_data=fread($connection, 10);
  echo "-> ".strlen($socket_data)."<br>"; flush();
  fwrite($connection, "\x2A\x01\x00\x02\x00\x11\x00\x00\x00\x01\x00\x01\x00\x09\x01\x01\x01\x01\x01\x01\x01\x01\x01");
  $socket_data=fread($connection, 1);
  echo "-> ".strlen($socket_data); flush();

?>

*?*
 [2006-04-11 11:24 UTC] sniper@php.net
socket_create(AF_INET, SOCK_RAW, SOL_UDP);
 [2006-04-11 20:01 UTC] psychi at freakmail dot de
Hello!

In how far is it a solution to establish a UDP connection if ICQ itself establishes a TCP connection and makes full use of the information the server sends? And I think 'SOL_STREAM' is the right type for this connection, because the manual tells 'The TCP protocol is based on this socket type.' and we want to use it. Or am I wrong?
 [2006-07-27 02:05 UTC] sniper@php.net
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Apr 23 15:01:32 2024 UTC