Send command and parameters in single operation.
This significantly improves the performance because it reduces the number of round trips needed.
This commit is contained in:
parent
3ae5e5e4a5
commit
485d9719b5
|
|
@ -267,20 +267,16 @@ ssize_t XVC_client::xfer_pkt(const string &instr,
|
||||||
uint8_t *rx, uint32_t rx_size)
|
uint8_t *rx, uint32_t rx_size)
|
||||||
{
|
{
|
||||||
ssize_t len = tx_size;
|
ssize_t len = tx_size;
|
||||||
|
vector<uint8_t> buffer(instr.size() + (tx) ? tx_size : 0);
|
||||||
|
memcpy(buffer.data(), instr.c_str(), instr.size());
|
||||||
|
if (tx)
|
||||||
|
memcpy(buffer.data() + instr.size(), tx, tx_size);
|
||||||
|
|
||||||
/* 1. instruction */
|
if (sendall(_sock, buffer.data(), buffer.size(), 0) == -1) {
|
||||||
if (sendall(_sock, instr.c_str(), instr.size(), 0) == -1) {
|
printError("Send failed");
|
||||||
printError("Send instruction failed");
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tx) {
|
|
||||||
if (sendall(_sock, tx, tx_size, 0) == -1) {
|
|
||||||
printError("Send error");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (rx) {
|
if (rx) {
|
||||||
len = recv(_sock, rx, rx_size, 0);
|
len = recv(_sock, rx, rx_size, 0);
|
||||||
if (len < 0) {
|
if (len < 0) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue