From b00af02316e64467e8219224a3de924640d9c765 Mon Sep 17 00:00:00 2001 From: fanasina Date: Wed, 3 Sep 2025 07:58:06 +0200 Subject: [PATCH] y_socket: debug recevefrom! change order cmd --- y_socket_t/src/y_socket_t/y_file_handler.c | 20 ++++++++++++++++++-- y_socket_t/src/y_socket_t/y_socket_t.c | 2 +- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/y_socket_t/src/y_socket_t/y_file_handler.c b/y_socket_t/src/y_socket_t/y_file_handler.c index e180c0a..19601f7 100644 --- a/y_socket_t/src/y_socket_t/y_file_handler.c +++ b/y_socket_t/src/y_socket_t/y_file_handler.c @@ -121,7 +121,8 @@ void* y_socket_send_file_for_all_nodes(void* arg){ return NULL; } - y_send_post_file_to_all_nodes(arg); + // y_send_post_file_to_all_nodes(arg); + for(struct list_y_NODE_T *local_list_current = nodes->begin_list; local_list_current; local_list_current=local_list_current->next ){ //memset(buf_send, 0, BUF_SIZE+1); while((retread = read(fd_file, buf_send, BUF_SIZE) ) > 0 ){ @@ -133,7 +134,7 @@ void* y_socket_send_file_for_all_nodes(void* arg){ ///printf("debug: sending response %s :\n",buf_send); //FOR_LIST_FORM_BEGIN(y_NODE_T, nodes) - for(struct list_y_NODE_T *local_list_current = nodes->begin_list; local_list_current; local_list_current=local_list_current->next ){ + //for(struct list_y_NODE_T *local_list_current = nodes->begin_list; local_list_current; local_list_current=local_list_current->next ) //memset(tempAddr, 0, BUF_SIZE+1); c_af=(local_list_current->value).addr.ss_family; #if TEMP_ADDR @@ -181,6 +182,21 @@ void* y_socket_send_file_for_all_nodes(void* arg){ } #endif //memset(buf_send, 0, BUF_SIZE+1); + retread = sprintf(buf_send, "post file %s", filename); + if(sendto(fds[(c_af==AF_INET6)].fd, + buf_send, retread, + /*msgRet, len_msgRet,*/ + 0, + (struct sockaddr*)&((local_list_current->value).addr), + (local_list_current->value).addr_len) != + retread + /*len_msgRet*/ + ){ + fprintf(stderr, "Error sending response to %s\n",tempAddr); + }else{ + printf("debug: sending response to < %s >",tempAddr); + } + } close(fd_file); diff --git a/y_socket_t/src/y_socket_t/y_socket_t.c b/y_socket_t/src/y_socket_t/y_socket_t.c index 4a74623..d7a83dc 100644 --- a/y_socket_t/src/y_socket_t/y_socket_t.c +++ b/y_socket_t/src/y_socket_t/y_socket_t.c @@ -363,7 +363,7 @@ void* y_socket_handler_(void *arg){ else if(strncmp(buf, "post", 4)==0){ if(strncmp(buf+5,"file",4)==0){ char filename[BUF_SIZE]; - strcpy(filename, buf + 9); + strcpy(filename, buf + 10); printf("debug: receve_from_node : file: %s\n",filename); receve_from_node(fds, filename, strlen(filename));