Small fixes to TCP example
- don't write more data to socket than is left in buffer - add missing LF in client printf()
This commit is contained in:
parent
e9a5f4ee16
commit
d4521b5973
@ -73,7 +73,7 @@ int main(int argc, char* argv[]) {
|
||||
uint16_t w_regs[2] = {123, 124};
|
||||
err = nmbs_write_multiple_registers(&nmbs, 26, 2, w_regs);
|
||||
if (err != NMBS_ERROR_NONE) {
|
||||
fprintf(stderr, "Error writing register at address 26 - %s", nmbs_strerror(err));
|
||||
fprintf(stderr, "Error writing register at address 26 - %s\n", nmbs_strerror(err));
|
||||
if (!nmbs_error_is_exception(err))
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -236,7 +236,7 @@ int32_t write_fd_linux(const uint8_t* buf, uint16_t count, int32_t timeout_ms, v
|
||||
}
|
||||
|
||||
if (ret == 1) {
|
||||
ssize_t w = write(fd, buf + total, count);
|
||||
ssize_t w = write(fd, buf + total, count - total);
|
||||
if (w == 0) {
|
||||
disconnect(arg);
|
||||
return -1;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user