mirror of
https://github.com/badaix/snapcast.git
synced 2025-05-17 11:06:16 +02:00
xxx
git-svn-id: svn://elaine/murooma/trunk@6 d8a302eb-03bc-478d-80e4-98257eca68ef
This commit is contained in:
parent
105ac263c0
commit
71949a8366
2 changed files with 20 additions and 3 deletions
18
client.cpp
18
client.cpp
|
@ -8,16 +8,30 @@
|
||||||
#include <zmq.hpp>
|
#include <zmq.hpp>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
#include <sys/time.h>
|
||||||
|
|
||||||
const size_t size(1024);
|
const size_t size(1024);
|
||||||
|
|
||||||
struct Chunk
|
struct Chunk
|
||||||
{
|
{
|
||||||
time_t timestamp;
|
timeval timestamp;
|
||||||
char payload[size];
|
char payload[size];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
std::string timeToStr(const timeval& timestamp)
|
||||||
|
{
|
||||||
|
char tmbuf[64], buf[64];
|
||||||
|
struct tm *nowtm;
|
||||||
|
time_t nowtime;
|
||||||
|
nowtime = timestamp.tv_sec;
|
||||||
|
nowtm = localtime(&nowtime);
|
||||||
|
strftime(tmbuf, sizeof tmbuf, "%Y-%m-%d %H:%M:%S", nowtm);
|
||||||
|
snprintf(buf, sizeof buf, "%s.%06d", tmbuf, timestamp.tv_usec);
|
||||||
|
return buf;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int main (int argc, char *argv[])
|
int main (int argc, char *argv[])
|
||||||
{
|
{
|
||||||
zmq::context_t context (1);
|
zmq::context_t context (1);
|
||||||
|
@ -46,6 +60,8 @@ int main (int argc, char *argv[])
|
||||||
// std::cout << "update\n";
|
// std::cout << "update\n";
|
||||||
for (size_t n=0; n<size; ++n)
|
for (size_t n=0; n<size; ++n)
|
||||||
std::cout << chunk->payload[n] << std::flush;
|
std::cout << chunk->payload[n] << std::flush;
|
||||||
|
|
||||||
|
std::cerr << timeToStr(chunk->timestamp) << "\n";
|
||||||
delete chunk;
|
delete chunk;
|
||||||
// std::cout << std::flush;
|
// std::cout << std::flush;
|
||||||
// std::cerr << "flushed\n";
|
// std::cerr << "flushed\n";
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
#include <sys/time.h>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
@ -19,7 +20,7 @@ const int size(1024);
|
||||||
|
|
||||||
struct Chunk
|
struct Chunk
|
||||||
{
|
{
|
||||||
time_t timestamp;
|
timeval timestamp;
|
||||||
char payload[size];
|
char payload[size];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -37,7 +38,7 @@ int main () {
|
||||||
while (!cin.get(c).eof())
|
while (!cin.get(c).eof())
|
||||||
{
|
{
|
||||||
if (idx == 0)
|
if (idx == 0)
|
||||||
time(&chunk.timestamp);
|
gettimeofday(&chunk.timestamp, 0);
|
||||||
|
|
||||||
// read(fd, &msg[0], size);
|
// read(fd, &msg[0], size);
|
||||||
chunk.payload[idx++] = c;
|
chunk.payload[idx++] = c;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue