Get listen working.
Setup poll handler.
sets[i]->names.used = 0;
sets[i]->buffers.used = 0;
+ sets[i]->polls.used = 0;
main->setting.state.status = f_string_dynamics_increase_by(main->program.parameters.array[parameters[i]].values.used / 2, &sets[i]->names);
macro_setting_load_handle_send_receive_error_continue_1(f_statuss_increase_by);
+ main->setting.state.status = f_polls_increase_by(main->program.parameters.array[parameters[i]].values.used / 2, &sets[i]->polls);
+
+ macro_setting_load_handle_send_receive_error_continue_1(f_polls_increase_by);
+
for (j = 0; j < main->program.parameters.array[parameters[i]].values.used; j += 2) {
// First parameter value represents the network address or the socket file path.
sets[i]->names.array[j].string[sets[i]->names.array[j].used] = 0;
sets[i]->sockets.array[j].domain = f_socket_protocol_family_local_e;
sets[i]->sockets.array[j].protocol = f_socket_protocol_tcp_e;
- sets[i]->sockets.array[j].type = f_socket_address_family_local_e;
+ sets[i]->sockets.array[j].type = f_socket_type_stream_e;
sets[i]->sockets.array[j].name = sets[i]->names.array[j];
}
else if (main->setting.flag & kt_tacocat_main_flag_resolve_classic_e) {
}
sets[i]->sockets.array[j].protocol = f_socket_protocol_tcp_e;
- sets[i]->sockets.array[j].type = host.h_addrtype;
+ sets[i]->sockets.array[j].type = f_socket_type_stream_e;
if (host.h_addrtype == f_socket_address_family_inet4_e) {
sets[i]->sockets.array[j].domain = f_socket_protocol_family_inet4_e;
}
++sets[i]->files.used;
+ ++sets[i]->polls.used;
++sets[i]->sockets.used;
++sets[i]->statuss.used;
++sets[i]->names.used;
"f_files_increase_by",
"f_network_from_ip_name",
"f_network_is_ip_address",
+ "f_polls_increase_by",
"f_socket_bind_inet4",
"f_socket_bind_inet6",
"f_socket_bind_local",
kt_tacocat_f_f_files_increase_by_e,
kt_tacocat_f_f_network_from_ip_name_e,
kt_tacocat_f_f_network_is_ip_address_e,
+ kt_tacocat_f_f_polls_increase_by_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,
} // for
f_files_resize(0, &sets[i]->files);
+ f_polls_resize(0, &sets[i]->polls);
f_sockets_resize(0, &sets[i]->sockets);
f_statuss_resize(0, &sets[i]->statuss);
* block_size: The size in bytes to used to represent a block when sending or receiving packets.
*
* files: An array of files for each socket.
+ * polls: An array of sockets to poll, specifically for passing to f_file_poll().
* sockets: An array of the network sockets.
* statuss: An array of statuses for each socket.
+ *
* names: An array of names for each socket.
* buffers: An array of buffers for sending or receiving data between clients for each socket.
*/
f_number_unsigned_t block_size;
f_files_t files;
+ f_polls_t polls;
f_sockets_t sockets;
f_statuss_t statuss;
+
f_string_dynamics_t names;
f_string_dynamics_t buffers;
} kt_tacocat_socket_set_t;
{ \
kt_tacocat_block_size_d, \
f_files_t_initialize, \
+ f_polls_t_initialize, \
f_sockets_t_initialize, \
f_statuss_t_initialize, \
f_string_dynamics_t_initialize, \
{ \
block_size, \
f_files_t_initialize, \
+ f_polls_t_initialize, \
f_sockets_t_initialize, \
f_statuss_t_initialize, \
f_string_dynamics_t_initialize, \
* receive: The socket set for receiving data receive clients.
* send: The socket set for sending data send clients.
*
- * buffer: A string buffer used for caching purposes.
+ * buffer: A string buffer used for caching purposes.
*/
#ifndef _di_kt_tacocat_setting_t_
typedef struct {
continue;
}
+
+ if (main->setting.receive.sockets.array[i].id == -1) {
+ main->setting.receive.polls.array[i].fd = -1;
+ main->setting.receive.polls.array[i].events = 0;
+ main->setting.receive.polls.array[i].revents = 0;
+ }
+ else {
+ main->setting.receive.polls.array[i].fd = main->setting.receive.sockets.array[i].id;
+ main->setting.receive.polls.array[i].events = f_poll_read_e | f_poll_urgent_e;
+ main->setting.receive.polls.array[i].revents = 0;
+ }
} // for
if (F_status_is_error_not(main->setting.state.status)) {
+ // @todo this is where another process should poll/wait for connections and such (in another thread/fork).
+ main->setting.state.status = f_file_poll(main->setting.receive.polls, 9000); // @todo temporarily set to 9 second(s).
+
+ // @todo handle errors, but this will be in a fork/thread.
+
main->setting.state.status = F_none;
}
}