Get the current state of the project in sync with the recent f_socket_connect() changes.
Currently, the send is failing on f_socket_write_stream() due to code 414 (F_pipe).
This is the next point of investigation.
sets[i]->array[j].status = F_okay;
sets[i]->array[j].socket.id = -1;
sets[i]->array[j].socket.id_data = -1;
+ sets[i]->array[j].socket.form = f_socket_address_form_generic_e;
sets[i]->array[j].write_state.conversion = f_conversion_data_base_10_c;
sets[i]->array[j].write_state.cache = &sets[i]->array[j].cache;
if (main->setting.state.status == F_network_version_four) {
host.h_addrtype = f_socket_address_family_inet4_e;
family.type = f_network_family_ip_4_e;
+ sets[i]->array[j].socket.form = f_socket_address_form_inet4_e;
}
else if (main->setting.state.status == F_network_version_six) {
host.h_addrtype = f_socket_address_family_inet6_e;
family.type = f_network_family_ip_6_e;
+ sets[i]->array[j].socket.form = f_socket_address_form_inet6_e;
}
else {
host.h_addrtype = 0;
family.type = f_network_family_none_e;
+ sets[i]->array[j].socket.form = f_socket_address_form_generic_e;
}
kt_tacocat_setting_load_address_port_extract(main, range_ip, &address, &port);
"f_network_from_ip_string",
"f_network_is_ip_address",
"f_socket_accept",
- "f_socket_bind_inet4",
- "f_socket_bind_inet6",
- "f_socket_bind_local",
+ "f_socket_bind",
"f_socket_close",
"f_socket_connect",
"f_socket_create",
kt_tacocat_f_f_network_from_ip_string_e,
kt_tacocat_f_f_network_is_ip_address_e,
kt_tacocat_f_f_socket_accept_e,
- kt_tacocat_f_f_socket_bind_inet4_e,
- kt_tacocat_f_f_socket_bind_inet6_e,
- kt_tacocat_f_f_socket_bind_local_e,
+ kt_tacocat_f_f_socket_bind_e,
kt_tacocat_f_f_socket_close_e,
kt_tacocat_f_f_socket_connect_e,
kt_tacocat_f_f_socket_create_e,
}
#endif // _di_kt_tacocat_print_error_
-#ifndef _di_kt_tacocat_print_error_on_buffer_too_large_
- f_status_t kt_tacocat_print_error_on_buffer_too_large(fl_print_t * const print, const f_string_static_t on, const f_string_static_t network, const f_number_unsigned_t size_expect, const f_number_unsigned_t size_got) {
-
- if (!print) return F_status_set_error(F_output_not);
- if (print->verbosity < f_console_verbosity_error_e) return F_output_not;
-
- f_file_stream_lock(print->to);
-
- fl_print_format("%[%QNetwork packet is too large for%] ", print->to, print->set->error, print->prefix, print->set->error);
- fl_print_format(f_string_format_Q_single_s.string, print->to, print->set->notable, on, print->set->notable);
- fl_print_format(" %[buffer for '%]", print->to, print->set->error, print->set->error, f_string_eol_s);
- fl_print_format(f_string_format_Q_single_s.string, print->to, print->set->notable, network, print->set->notable);
- fl_print_format("%[', the maximum size is%] ", print->to, print->set->error, print->set->error);
- fl_print_format("%[%ul%]", print->to, print->set->notable, size_expect, print->set->notable);
- fl_print_format("%[, and the provided size is%] ", print->to, print->set->error, print->set->error);
- fl_print_format("%[%ul%]", print->to, print->set->notable, size_got, print->set->notable);
- fl_print_format(f_string_format_sentence_end_s.string, print->to, print->set->error, print->set->error, f_string_eol_s);
-
- f_file_stream_unlock(print->to);
-
- return F_okay;
- }
-#endif // _di_kt_tacocat_print_error_on_buffer_too_large_
-
#ifndef _di_kt_tacocat_print_error_on_file_too_large_
f_status_t kt_tacocat_print_error_on_file_too_large(fl_print_t * const print, f_string_static_t file, const f_string_static_t on, const f_string_static_t network, const f_number_unsigned_t size_expect, const f_number_unsigned_t size_got) {
}
#endif // _di_kt_tacocat_print_error_on_file_send_
+#ifndef _di_kt_tacocat_print_error_on_packet_invalid_
+ f_status_t kt_tacocat_print_error_on_packet_invalid(fl_print_t * const print, const f_string_static_t on, const f_string_static_t network) {
+
+ if (!print) return F_status_set_error(F_output_not);
+ if (print->verbosity < f_console_verbosity_error_e) return F_output_not;
+
+ f_file_stream_lock(print->to);
+
+ fl_print_format("%[%QNetwork packet is invalid for%] ", print->to, print->set->error, print->prefix, print->set->error);
+ fl_print_format(f_string_format_Q_single_s.string, print->to, print->set->notable, on, print->set->notable);
+ fl_print_format(" %[buffer for '%]", print->to, print->set->error, print->set->error, f_string_eol_s);
+ fl_print_format(f_string_format_Q_single_s.string, print->to, print->set->notable, network, print->set->notable);
+ fl_print_format("%['.%]%r", print->to, print->set->error, print->set->error, f_string_eol_s);
+
+ f_file_stream_unlock(print->to);
+
+ return F_okay;
+ }
+#endif // _di_kt_tacocat_print_error_on_packet_invalid_
+
#ifndef _di_kt_tacocat_print_error_on_max_retries_
f_status_t kt_tacocat_print_error_on_max_retries(fl_print_t * const print, const f_string_static_t on, const f_string_static_t network, const f_string_static_t name) {
#endif // _di_kt_tacocat_print_error_on_
/**
- * Print network-related error message for when buffer is too large to accept additional packet blocks.
- *
- * @param print
- * The output structure to print to.
- *
- * This does not alter print.custom.setting.state.status.
- * @param on
- * The network connection direction, which should either be "receive" or "send".
- * @param network
- * The name of the network in which the error is related.
- * @param size_max
- * The maximum buffer size.
- * @param size_got
- * The provided buffer size.
- *
- * @return
- * F_okay on success.
- * F_output_not on success, but no printing is performed.
- *
- * F_output_not (with error bit) if setting is NULL.
- *
- * @see fll_error_file_print()
- */
-#ifndef _di_kt_tacocat_print_error_on_buffer_too_large_
- extern f_status_t kt_tacocat_print_error_on_buffer_too_large(fl_print_t * const print, const f_string_static_t on, const f_string_static_t network, const f_number_unsigned_t size_expect, const f_number_unsigned_t size_got);
-#endif // _di_kt_tacocat_print_error_on_buffer_too_large_
-
-/**
* Print network-related error message for when file is too large to send.
*
* @param print
#endif // _di_kt_tacocat_print_error_on_file_send_
/**
+ * Print network-related error message for when a packet is invalid.
+ *
+ * @param print
+ * The output structure to print to.
+ *
+ * This does not alter print.custom.setting.state.status.
+ * @param on
+ * The network connection direction, which should either be "receive" or "send".
+ * @param network
+ * The name of the network in which the error is related.
+ *
+ * @return
+ * F_okay on success.
+ * F_output_not on success, but no printing is performed.
+ *
+ * F_output_not (with error bit) if setting is NULL.
+ *
+ * @see fll_error_file_print()
+ */
+#ifndef _di_kt_tacocat_print_error_on_packet_invalid_
+ extern f_status_t kt_tacocat_print_error_on_packet_invalid(fl_print_t * const print, const f_string_static_t on, const f_string_static_t network);
+#endif // _di_kt_tacocat_print_error_on_packet_invalid_
+
+/**
* Print error message regarding maximum retries after error reached.
*
* This could be on any error, such as errors on file load, memory, access, or network failures.
for (main->setting.receive.array[i].retry = 0; main->setting.receive.array[i].retry < kt_tacocat_startup_retry_max_d; ++main->setting.receive.array[i].retry) {
- if (main->setting.receive.array[i].socket.domain == f_socket_protocol_family_inet4_e) {
- main->setting.receive.array[i].status = f_socket_bind_inet4(&main->setting.receive.array[i].socket);
- }
- else if (main->setting.receive.array[i].socket.domain == f_socket_protocol_family_inet6_e) {
- main->setting.receive.array[i].status = f_socket_bind_inet6(&main->setting.receive.array[i].socket);
- }
- else if (main->setting.receive.array[i].socket.domain == f_socket_protocol_family_local_e) {
- main->setting.receive.array[i].status = f_socket_bind_local(&main->setting.receive.array[i].socket);
+ if (main->setting.receive.array[i].socket.form == f_socket_address_form_inet4_e || main->setting.receive.array[i].socket.form == f_socket_address_form_inet6_e || main->setting.receive.array[i].socket.form == f_socket_address_form_local_e) {
+ main->setting.receive.array[i].status = f_socket_bind(&main->setting.receive.array[i].socket);
}
else {
main->setting.status_receive = F_status_set_error(F_parameter);
kt_tacocat_print_error_on_busy(&main->program.error, kt_tacocat_receive_s, main->setting.receive.array[i].network);
}
else {
- kt_tacocat_print_error_status(&main->program.error, main->setting.receive.array[i].socket.domain == f_socket_protocol_family_inet4_e
- ? macro_kt_tacocat_f(f_socket_bind_inet4)
- : main->setting.receive.array[i].socket.domain == f_socket_protocol_family_inet6_e
- ? macro_kt_tacocat_f(f_socket_bind_inet6)
- : macro_kt_tacocat_f(f_socket_bind_local),
- main->setting.status_receive
- );
+ kt_tacocat_print_error_status(&main->program.error, macro_kt_tacocat_f(f_socket_bind), main->setting.status_receive);
}
continue;
for (main->setting.send.array[i].retry = 0; main->setting.send.array[i].retry < kt_tacocat_startup_retry_max_d; ++main->setting.send.array[i].retry) {
if (main->setting.send.array[i].socket.domain == f_socket_protocol_family_inet4_e || main->setting.send.array[i].socket.domain == f_socket_protocol_family_inet6_e || main->setting.send.array[i].socket.domain == f_socket_protocol_family_local_e) {
- main->setting.send.array[i].status = f_socket_connect(main->setting.send.array[i].socket); // @fixme this is currently failing because part of the parameters is invalid (figure out why).
+ main->setting.send.array[i].status = f_socket_connect(&main->setting.send.array[i].socket);
// The id_data socket ID is the same when sending (writing) to the socket.
if (F_status_is_error_not(main->setting.send.array[i].status)) {
kt_tacocat_print_error_on_packet_too_small(&main->program.error, kt_tacocat_receive_s, set->network, kt_tacocat_packet_peek_d, set->buffer.used);
set->buffer.used = 0;
+ set->flag = 0;
+ set->packet.control = 0;
+ set->packet.size = 0;
set->retry = 0;
set->status = F_status_set_error(F_packet_too_small);
- set->flag = 0;
return;
}
set->flag = 0;
set->packet.control = 0;
set->packet.size = 0;
+ set->retry = 0;
set->status = F_status_set_error(F_packet_too_small);
return;
set->status = f_fss_simple_packet_extract_range(set->buffer, &set->packet);
macro_kt_receive_process_begin_handle_error_exit_1(main, f_fss_simple_packet_extract_range, set->network, set->status, set->name, set->flag);
- if (set->status == F_packet_too_small || set->packet.size < kt_tacocat_packet_minimum_d) {
- kt_tacocat_print_error_on_packet_too_small(&main->program.error, kt_tacocat_receive_s, set->network, kt_tacocat_packet_peek_d, set->buffer.used);
-
+ if (set->status == F_packet_too_small || set->packet.size < kt_tacocat_packet_minimum_d || set->packet.size > main->setting.max_buffer) {
set->buffer.used = 0;
- set->flag = 0;
- set->packet.control = 0;
- set->packet.size = 0;
- set->status = F_status_set_error(F_packet_too_small);
- return;
- }
-
- if (main->setting.flag & kt_tacocat_main_flag_max_buffer_e) {
- if (set->packet.size > main->setting.max_buffer) {
- set->buffer.used = 0;
+ if (set->buffer.size > kt_tacocat_max_maintain_d) {
+ set->status = f_memory_array_resize(kt_tacocat_max_maintain_d, sizeof(f_char_t), (void **) &set->buffer.string, &set->buffer.used, &set->buffer.size);
- if (set->buffer.size > kt_tacocat_max_maintain_d) {
- set->status = f_memory_array_resize(kt_tacocat_max_maintain_d, sizeof(f_char_t), (void **) &set->buffer.string, &set->buffer.used, &set->buffer.size);
-
- // Report the resize error but do not fail.
- if (F_status_is_error(set->status)) {
- kt_tacocat_print_error_on(&main->program.error, macro_kt_tacocat_f(f_memory_array_resize), kt_tacocat_receive_s, set->network, set->status, set->name);
- }
+ // Report the resize error but do not fail.
+ if (F_status_is_error(set->status)) {
+ kt_tacocat_print_error_on(&main->program.error, macro_kt_tacocat_f(f_memory_array_resize), kt_tacocat_receive_s, set->network, set->status, set->name);
}
+ }
+ set->flag = 0;
+ set->packet.control = 0;
+ set->packet.size = 0;
+ set->retry = 0;
+
+ if (set->status == F_packet_too_small || set->packet.size < kt_tacocat_packet_minimum_d) {
set->status = F_status_set_error(F_packet_too_large);
- set->flag = 0;
+ }
+ else {
+ set->status = F_status_set_error(F_packet_too_small);
+ }
- kt_tacocat_print_error_on_buffer_too_large(&main->program.error, kt_tacocat_receive_s, set->network, main->setting.max_buffer, set->packet.size);
+ kt_tacocat_print_error_on_packet_invalid(&main->program.error, kt_tacocat_receive_s, set->network);
- return;
- }
+ return;
}
set->flag |= kt_tacocat_socket_flag_receive_block_payload_e;
}
if (set->flag == kt_tacocat_socket_flag_send_connect_e) {
- // @fixme this is already performed, so do not do this here, the whole kt_tacocat_socket_flag_send_connect_e stage and kt_tacocat_send_connect_s should be removed.
- //set->status = f_socket_connect(set->socket);
- //macro_kt_send_process_handle_error_exit_1(main, f_socket_connect, kt_tacocat_send_connect_s, set->network, set->status, set->name, set->flag);
+ if (set->socket.id == -1) {
+ set->status = f_socket_connect(&set->socket);
+ macro_kt_send_process_handle_error_exit_1(main, f_socket_connect, kt_tacocat_send_connect_s, set->network, set->status, set->name, set->flag);
+ }
+
+ if (set->socket.id_data == -1) {
+ set->socket.id_data = set->socket.id;
+ }
- //set->socket.id_data = set->socket.id;
set->flag = kt_tacocat_socket_flag_send_header_e;
}
if (set->flag == kt_tacocat_socket_flag_send_header_e) {
size_t written = 0;
+ set->socket.size_write = set->size_done + set->size_block > set->header.used ? set->header.used - set->size_done : set->size_block;
+
set->status = f_socket_write_stream(&set->socket, 0, (void *) (set->header.string + set->size_done), &written);
macro_kt_send_process_handle_error_exit_1(main, f_socket_write_stream, kt_tacocat_send_header_s, set->network, set->status, set->name, set->flag);
if (set->flag == kt_tacocat_socket_flag_send_payload_e) {
size_t written = 0;
+ set->socket.size_write = set->size_done + set->size_block > set->buffer.used ? set->buffer.used - set->size_done : set->size_block;
+
set->status = f_socket_write_stream(&set->socket, 0, (void *) (set->buffer.string + set->size_done), &written);
macro_kt_send_process_handle_error_exit_1(main, f_socket_write_stream, kt_tacocat_send_payload_s, set->network, set->status, set->name, set->flag);