version 4.7.0
add PIEthernet socket options setReadBufferSize() and setWriteBufferSize() add PIByteArray::dataAs
This commit is contained in:
@@ -163,6 +163,30 @@ PIEthernet::~PIEthernet() {
|
||||
}
|
||||
|
||||
|
||||
void PIEthernet::setReadTimeout(PISystemTime tm) {
|
||||
setProperty("readTimeout", tm);
|
||||
applyTimeouts();
|
||||
}
|
||||
|
||||
|
||||
void PIEthernet::setWriteTimeout(PISystemTime tm) {
|
||||
setProperty("writeTimeout", tm);
|
||||
applyTimeouts();
|
||||
}
|
||||
|
||||
|
||||
void PIEthernet::setReadBufferSize(int bytes) {
|
||||
rcv_buf = bytes;
|
||||
applyBuffers();
|
||||
}
|
||||
|
||||
|
||||
void PIEthernet::setWriteBufferSize(int bytes) {
|
||||
snd_buf = bytes;
|
||||
applyBuffers();
|
||||
}
|
||||
|
||||
|
||||
void PIEthernet::construct() {
|
||||
// piCout << " PIEthernet" << uint(this);
|
||||
setOption(BlockingWrite);
|
||||
@@ -211,6 +235,7 @@ void PIEthernet::init() {
|
||||
}
|
||||
applyParameters();
|
||||
applyTimeouts();
|
||||
applyBuffers();
|
||||
applyOptInt(IPPROTO_IP, IP_TTL, TTL());
|
||||
// piCoutObj << "inited" << path();
|
||||
}
|
||||
@@ -296,6 +321,7 @@ bool PIEthernet::openDevice() {
|
||||
while (!mcast_queue.isEmpty())
|
||||
joinMulticastGroup(mcast_queue.dequeue());
|
||||
applyTimeouts();
|
||||
applyBuffers();
|
||||
applyOptInt(IPPROTO_IP, IP_TTL, TTL());
|
||||
addr_lr.clear();
|
||||
return true;
|
||||
@@ -338,9 +364,22 @@ void PIEthernet::applyTimeouts() {
|
||||
}
|
||||
|
||||
|
||||
void PIEthernet::applyBuffers() {
|
||||
if (sock < 0) return;
|
||||
if (rcv_buf > 0) ethSetsockoptInt(sock, SOL_SOCKET, SO_RCVBUF, rcv_buf);
|
||||
if (snd_buf > 0) {
|
||||
if (sock_s != sock) {
|
||||
ethSetsockoptInt(sock_s, SOL_SOCKET, SO_SNDBUF, snd_buf);
|
||||
} else {
|
||||
ethSetsockoptInt(sock, SOL_SOCKET, SO_SNDBUF, snd_buf);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void PIEthernet::applyTimeout(int fd, int opt, PISystemTime tm) {
|
||||
if (fd == 0) return;
|
||||
// piCoutObj << "setReadIsBlocking" << yes;
|
||||
// piCoutObj << "setReadIsBlocking" << yes;
|
||||
#ifdef WINDOWS
|
||||
DWORD _tm = tm.toMilliseconds();
|
||||
#else
|
||||
|
||||
Reference in New Issue
Block a user