-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchannel_t.cpp
More file actions
61 lines (52 loc) · 1.42 KB
/
channel_t.cpp
File metadata and controls
61 lines (52 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
//#include "channel_t.h"
//namespace xennet
//{
//channel_t::channel_t(QObject *parent) :
// QObject(parent)
//{
//}
//void channel_t::connect(const char* host, ushort port)
//{
// if (c || s) throw std::runtime_error("socket not null");
//// c = new QTcpSocket();
// c->connectToHost(host, port);
//}
//void channel_t::listen(ushort port)
//{
// if (c || s) throw std::runtime_error("socket not null");
// s = new QTcpServer();
// if (!s->listen(QHostAddress::Any, port))
// throw std::runtime_error("listen failed");
//}
//shr_stream channel_t::accept()
//{
// if (!s) throw std::runtime_error("accepting without init");
//// return new channel_t(s->nextPendingConnection());
//}
//stream_t& channel_t::operator<<(const bstr& m)
//{
// if (!c) throw std::runtime_error("socket not initialized");
// uint32_t sz = m.size();
// if (c->write((const char*)&sz, sizeof(uint32_t)) != sizeof(uint32_t))
// throw std::runtime_error("write failed");
// if (c->write(m.c_str(), sz) != sz)
// throw std::runtime_error("write failed");
// return *this;
//}
//stream_t& channel_t::operator>>(bstr& m)
//{
// uint32_t sz;
//// if (c->read((const char*)&sz, sizeof(uint32_t)) != sizeof(uint32_t))
//// throw std::runtime_error("read failed");
// char *a = new char[sz];
// if (c->read(a, sz) != sz)
// throw std::runtime_error("read failed");
// m = a;
// delete[] a;
// return *this;
//}
//channel_t::~channel_t()
//{
// if (s) delete s;
//}
//}