mirror of
https://github.com/badaix/snapcast.git
synced 2025-08-02 08:09:35 +02:00
xxx
git-svn-id: svn://elaine/murooma/trunk@154 d8a302eb-03bc-478d-80e4-98257eca68ef
This commit is contained in:
parent
01b887df45
commit
a1487e5081
2 changed files with 21 additions and 5 deletions
|
@ -62,7 +62,13 @@ public:
|
|||
{
|
||||
shared_ptr<WireChunk> chunk(chunks.pop());
|
||||
boost::system::error_code error;
|
||||
boost::asio::write(*socket_, boost::asio::buffer(chunk.get(), sizeof(WireChunk)), boost::asio::transfer_all(), error);
|
||||
size_t written = 0;
|
||||
do
|
||||
{
|
||||
written += boost::asio::write_some(*socket_, boost::asio::buffer(chunk.get() + written, sizeof(WireChunk) - written), error);
|
||||
}
|
||||
while (written < sizeof(WireChunk));
|
||||
|
||||
if (error == boost::asio::error::eof)
|
||||
break; // Connection closed cleanly by peer.
|
||||
else if (error)
|
||||
|
|
14
client.cpp
14
client.cpp
|
@ -45,17 +45,27 @@ void player()
|
|||
{
|
||||
try
|
||||
{
|
||||
cout << "connect\n";
|
||||
tcp::socket s(io_service);
|
||||
s.connect(*iterator);
|
||||
boost::system::error_code error;
|
||||
|
||||
WireChunk* wireChunk = new WireChunk();
|
||||
while (true)
|
||||
{
|
||||
WireChunk* wireChunk = new WireChunk();
|
||||
size_t len = s.read_some(boost::asio::buffer(wireChunk, sizeof(WireChunk)));
|
||||
size_t toRead = sizeof(WireChunk);
|
||||
size_t len = 0;
|
||||
do
|
||||
{
|
||||
len += s.read_some(boost::asio::buffer(wireChunk + len, toRead), error);
|
||||
toRead = sizeof(WireChunk) - len;
|
||||
cout << "len: " << len << "\ttoRead: " << toRead << "\n";
|
||||
if (error == boost::asio::error::eof)
|
||||
break;
|
||||
}
|
||||
while (toRead > 0);
|
||||
|
||||
cout << "new chunk\n";
|
||||
stream->addChunk(new Chunk(wireChunk));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue