Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F97617131
PhutilChannelTestCase.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Sun, Jan 5, 18:29
Size
875 B
Mime Type
text/x-php
Expires
Tue, Jan 7, 18:29 (2 d)
Engine
blob
Format
Raw Data
Handle
23366887
Attached To
rPHU libphutil
PhutilChannelTestCase.php
View Options
<?php
final
class
PhutilChannelTestCase
extends
PhutilTestCase
{
public
function
testChannelBasics
()
{
list
(
$x
,
$y
)
=
PhutilSocketChannel
::
newChannelPair
();
$str_len_8
=
'abcdefgh'
;
$str_len_4
=
'abcd'
;
// Do a write with no buffer limit.
$x
->
write
(
$str_len_8
);
while
(
true
)
{
$x
->
update
();
$y
->
update
();
$read
=
$y
->
read
();
if
(
strlen
(
$read
))
{
break
;
}
}
// We expect to read the entire message.
$this
->
assertEqual
(
$str_len_8
,
$read
);
// Again, with a read buffer limit.
$y
->
setReadBufferSize
(
4
);
$x
->
write
(
$str_len_8
);
while
(
true
)
{
$x
->
update
();
$y
->
update
();
$read
=
$y
->
read
();
if
(
strlen
(
$read
))
{
break
;
}
}
// We expect to see only the first 4 bytes of the message.
$this
->
assertEqual
(
$str_len_4
,
$read
);
}
}
Event Timeline
Log In to Comment