328 |
int socket_write(Socket_T S, void *b, int size) { |
int socket_write(Socket_T S, void *b, int size) { |
329 |
|
|
330 |
int n= 0; |
int n= 0; |
331 |
char *p= b; |
void *p= b; |
332 |
|
|
333 |
ASSERT(S); |
ASSERT(S); |
334 |
|
|
335 |
while(size > 0) { |
while(size > 0) { |
336 |
|
|
337 |
if(S->ssl) { |
if(S->ssl) { |
338 |
n= send_ssl_socket(S->ssl, (void *) p, size); |
n= send_ssl_socket(S->ssl, p, size); |
339 |
} else { |
} else { |
340 |
n= sock_write(S->socket, (void *) p, size); |
n= sock_write(S->socket, p, size); |
341 |
} |
} |
342 |
|
|
343 |
if(n <= 0) break; |
if(n <= 0) break; |
366 |
int socket_read(Socket_T S, void *b, int size) { |
int socket_read(Socket_T S, void *b, int size) { |
367 |
|
|
368 |
int n= 0; |
int n= 0; |
369 |
char *p= b; |
void *p= b; |
370 |
int timeout= 0; |
int timeout= 0; |
371 |
|
|
372 |
ASSERT(S); |
ASSERT(S); |
373 |
|
|
374 |
timeout= S->timeout; |
timeout= S->timeout; |
375 |
|
|
376 |
do { |
while(size > 0) { |
377 |
if(S->ssl) { |
if(S->ssl) { |
378 |
n= recv_ssl_socket(S->ssl, (void *) p, size, timeout); |
n= recv_ssl_socket(S->ssl, p, size, timeout); |
379 |
} else { |
} else { |
380 |
n= sock_read(S->socket, (void *) p, size, timeout); |
n= sock_read(S->socket, p, size, timeout); |
381 |
} |
} |
382 |
if(n <= 0) break; |
if(n <= 0) break; |
383 |
p+= n; |
p+= n; |
386 |
* available data, otherwise we return with what we have read |
* available data, otherwise we return with what we have read |
387 |
*/ |
*/ |
388 |
timeout= 0; |
timeout= 0; |
389 |
} while(size > 0); |
} |
390 |
|
|
391 |
if(n < 0 && p==b) { |
if(n < 0 && p==b) { |
392 |
return -1; |
return -1; |