From ce5446c9e4df343a95b8eaf288e7172ce8f1c820 Mon Sep 17 00:00:00 2001 From: jede Date: Tue, 23 Apr 2024 00:17:32 +0200 Subject: [PATCH] fix close --- src/socket_close.s | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/socket_close.s b/src/socket_close.s index 2fa0ad7..2b1a400 100644 --- a/src/socket_close.s +++ b/src/socket_close.s @@ -11,19 +11,33 @@ SOCKET_CLOSE_DEBUG=0 .import ch395_get_cmd_status .import ch395_get_socket_status_sn .import socket_state +.import ch395_clear_recv_buf_sn .proc socket_close ;;@brief Close socket ;;@inputX The socket id + lda socket_state,x + cmp #SOCK_DGRAM + bne @is_not_tcp_connexion + + txa + jsr ch395_tcp_disconnect_sn ; Modify Y and A in v2024.2 ch395 lib + +@is_not_tcp_connexion: lda #$00 sta socket_state,x - ; Close socket + txa + ; Flush buffers + pha + lda curl_current_socket + jsr ch395_clear_recv_buf_sn + ; Close socket + pla jsr ch395_close_socket_sn - rts .endproc