tools/hexnet: Reduce redundant code
parent
f681c54c82
commit
89cfb9d850
|
@ -68,20 +68,11 @@ void signalHandler(int signal) {
|
|||
void readFromTCPSocket() {
|
||||
ssize_t byteCount;
|
||||
uint8_t buffer[1536];
|
||||
if (outgoing) {
|
||||
while (!exitProgram && (byteCount = tcpConnector.read(buffer, sizeof(buffer))) > 0) {
|
||||
for (ssize_t i=0; i<byteCount; i++) {
|
||||
std::cout << std::hex << std::setfill('0') << std::setw(2) << (short) buffer[i] << " ";
|
||||
}
|
||||
std::cout.flush();
|
||||
}
|
||||
} else {
|
||||
while (!exitProgram && (byteCount = tcpSocket.read(buffer, sizeof(buffer))) > 0) {
|
||||
for (ssize_t i=0; i<byteCount; i++) {
|
||||
std::cout << std::hex << std::setfill('0') << std::setw(2) << (short) buffer[i] << " ";
|
||||
}
|
||||
std::cout.flush();
|
||||
while (!exitProgram && (outgoing? (byteCount = tcpConnector.read(buffer, sizeof(buffer))) > 0 : (byteCount = tcpSocket.read(buffer, sizeof(buffer))) > 0)) {
|
||||
for (ssize_t i=0; i<byteCount; i++) {
|
||||
std::cout << std::hex << std::setfill('0') << std::setw(2) << (short) buffer[i] << " ";
|
||||
}
|
||||
std::cout.flush();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue