Skip to content

Commit eae21a9

Browse files
committed
COMMON: Fixes 'Socket Client doesn't receive byte with value 13' #112
1 parent 2bbdfe4 commit eae21a9

File tree

5 files changed

+20
-6
lines changed

5 files changed

+20
-6
lines changed

ChangeLog

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
2021-06-05 (12.22)
2+
COMMON: Fixes 'Socket Client doesn't receive byte with value 13' #112
3+
14
2021-05-03 (12.22)
25
COMMON: Fix array access regression
36

src/common/fs_socket_client.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,8 +202,16 @@ int sockcl_write(dev_file_t *f, byte *data, uint32_t size) {
202202
* read from a socket
203203
*/
204204
int sockcl_read(dev_file_t *f, byte *data, uint32_t size) {
205-
f->drv_dw[0] = (uint32_t) net_input((socket_t) (long) f->handle, (char *)data, size, NULL);
206-
return (((long) f->drv_dw[0]) <= 0) ? 0 : (long) f->drv_dw[0];
205+
int result;
206+
if (f->handle != -1) {
207+
f->drv_dw[0] = (uint32_t) net_input((socket_t) (long) f->handle, (char *)data, size, NULL);
208+
result = (((long) f->drv_dw[0]) <= 0) ? 0 : (long) f->drv_dw[0];
209+
} else {
210+
err_network();
211+
data[0] = 0;
212+
result = 0;
213+
}
214+
return result;
207215
}
208216

209217
/*

src/common/inet2.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -169,10 +169,8 @@ int net_input(socket_t s, char *buf, int size, const char *delim) {
169169
return count; // delimiter found
170170
}
171171
}
172-
if (ch != '\015') { // ignore it
173-
buf[count] = ch;
174-
count += bytes; // actually ++
175-
}
172+
buf[count] = ch;
173+
count += bytes;
176174
}
177175
}
178176

src/common/sberr.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,10 @@ void err_memory() {
351351
rt_raise(ERR_MEMORY);
352352
}
353353

354+
void err_network() {
355+
rt_raise(ERR_NETWORK);
356+
}
357+
354358
/**
355359
* the DONE message
356360
*/

src/common/sberr.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ void err_ref_circ_var();
7878
void err_array();
7979
void err_form_input();
8080
void err_memory();
81+
void err_network();
8182
void err_throw(const char *fmt, ...);
8283
int err_handle_error(const char *err, var_p_t var);
8384
void inf_done(void);

0 commit comments

Comments
 (0)