21 #define READ_HEADER_SIZE 12 36 #define TMOUT_PENDING_CONN_TMOUT 3600 37 #define MAX_TMOUT_PENDING_CONNS 10 69 (vtohl(dna_connp->
buffer[1]) == 0) &&
76 (vtohl(dna_connp->
buffer[1]) == 0) &&
138 register int read_size, next_size;
162 read_size = ((next_size -
size) > max_io_data) ?
163 max_io_data : next_size -
size;
167 read_size, ast_read_h);
171 if(errno == ENOTSOCK)
185 switch(dna_connp->
state)
192 next_size = vtohl(dna_connp->
buffer[1]);
237 register int tcpip_code, read_size;
250 (
int *) realloc(dna_connp->
buffer, (
size_t)
size);
255 read_size = (size > max_io_data) ? max_io_data :
size ;
258 read_size, ast_read_h);
272 register int size_left, wrote;
276 int retries = WRITE_RETRIES, retrying = 0;
277 float wait_time = 0.01;
285 size = (size_left > max_io_data) ? max_io_data : size_left ;
295 if(retries == WRITE_RETRIES_WNG)
301 lib$wait(&wait_time);
331 }
while(size_left > 0);
338 register int tcpip_code;
417 int tcpip_code, ret = 1;
434 dna_connp->writing =
FALSE;
443 dna_connp->writing =
FALSE;
465 headerp = &(pktp->header);
470 memcpy(pktp->data, (
char *)buffer, (
size_t)size);
484 static void ast_conn_h(
int handle,
int svr_conn_id,
int protocol)
487 register int tcpip_code;
488 register int conn_id;
538 pending_connp = &Pending_conns[1];
540 for( i = 1; i <
size; i++, pending_connp++ )
542 pending_connp = &Pending_conns_tmout[1];
544 for( i = 1; i < size; i++, pending_connp++ )
551 int dna_open_server(
char *task,
void (*read_ast)(),
int *protocol,
int *port,
void (*error_ast)())
554 register int tcpip_code;
555 register int conn_id;
565 *protocol = PROTOCOL;
623 register int i,
size;
626 extern time_t
time();
630 pending_connp = &Pending_conns[1];
636 pending_connp = &Pending_conns_tmout[1];
642 for( i = 1; i <
size; i++, pending_connp++ )
644 if( pending_connp->
task_name[0] ==
'\0' )
648 pending_connp->
port = port;
664 pending_connp = &Pending_conns_tmout[oldesti];
667 pending_connp->
port = port;
678 register int i,
size;
683 pending_connp = &Pending_conns[1];
688 pending_connp = &Pending_conns_tmout[1];
690 curr_time =
time(NULL);
691 for( i = 1; i <
size; i++, pending_connp++ )
693 if( pending_connp->
task_name[0] !=
'\0' )
701 pending_connp = &Pending_conns_tmout[1];
703 for( i = 1; i <
size; i++, pending_connp++ )
705 if( (!strcmp(pending_connp->
node_name, node)) &&
706 (!strcmp(pending_connp->
task_name, task)) &&
707 (pending_connp->
port == port) &&
708 (pending_connp->
src_type == src_type))
723 pending_connp = &Pending_conns[
id];
727 pending_connp = &Pending_conns_tmout[
id];
733 int dna_open_client(
char *server_node,
char *server_task,
int port,
int server_protocol,
734 void (*read_ast)(),
void (*error_ast)(),
SRC_TYPES src_type)
738 register int tcpip_code, conn_id,
id;
741 char src_type_str[64];
743 if(server_protocol){}
763 if(!strstr(server_node,
"fidel"))
769 strcpy(src_type_str,
"Server");
771 strcpy(src_type_str,
"Client");
773 strcpy(src_type_str,
"Unknown type");
774 sprintf( str,
"%s Connecting to %s on %s",
775 src_type_str, server_task, server_node );
776 if(!strcmp(server_task,
"DIM_DNS"))
780 ins_pend_conn(server_node, server_task, port, src_type, 0, 0);
789 if( (
id =
find_pend_conn(server_node, server_task, port, src_type, 0)) )
792 strcpy(src_type_str,
"Server");
794 strcpy(src_type_str,
"Client");
796 strcpy(src_type_str,
"Unknown type");
797 sprintf( str,
"%s Connection established to", src_type_str);
798 if(!strcmp(server_task,
"DIM_DNS"))
821 tcpip_code =
dna_write_nowait(conn_id, &local_buffer,
sizeof(local_buffer));
825 printf(
" Client Establishing Connection: Couldn't write to Conn %3d : Server %s@%s\n",conn_id,
831 read_ast(conn_id, NULL, 0,
STA_CONN);
880 printf(
"%s", routine_name);
884 printf(
" %s on node %s",
898 printf(
": %s\n",str);
903 void dna_report_error(
int conn_id,
int code,
char *routine_name,
int severity,
int errcode)
905 char str[128], msg[1024];
908 sprintf(msg,
"%s", routine_name);
static void rel_pend_conn(int id, int type)
void dna_report_error_old(int conn_id, int code, char *routine_name)
static void ast_read_h(int conn_id, int status, int size)
#define TMOUT_PENDING_CONN_TMOUT
int tcpip_start_listen(int conn_id, void(*ast_routine)())
void dna_test_write(int conn_id)
static int dna_write_bytes(int conn_id, void *buffer, int size, int nowait)
int Tcpip_max_io_data_read
int dna_write(int conn_id, void *buffer, int size)
_DIM_PROTO(static void ast_read_h,(int conn_id, int status, int size))
static int DNA_Initialized
char node_name[MAX_NODE_NAME]
int dna_open_client(char *server_node, char *server_task, int port, int server_protocol, void(*read_ast)(), void(*error_ast)(), SRC_TYPES src_type)
DllExp DIM_NOSHARE NET_CONNECTION * Net_conns
void * id_get_ptr(int id, SRC_TYPES type)
void tcpip_get_error(char *str, int code)
int dna_close(int conn_id)
void conn_free(int conn_id)
void dna_rem_test_write(int conn_id)
void dna_set_test_write(int conn_id, int time)
static PENDING_OPEN Pending_conns[MAX_CONNS]
static void read_data(int conn_id)
static int do_dna_write(int id)
void conn_arr_create(SRC_TYPES type)
int tcpip_would_block(int code)
static void ast_conn_h(int handle, int svr_conn_id, int protocol)
int tcpip_write_nowait(int conn_id, char *buffer, int size)
void dtq_start_timer(int time, void(*user_routine)(), dim_long tag)
void tcpip_rem_test_write(int conn_id)
int tcpip_start_read(int conn_id, char *buffer, int size, void(*ast_routine)())
int tcpip_close(int conn_id)
int dna_get_node_task(int conn_id, char *node, char *task)
Warning because the service this data corrsponds to might have been last updated longer ago than Local time
void dna_report_error(int conn_id, int code, char *routine_name, int severity, int errcode)
static void save_node_task(int conn_id, DNA_NET *buffer)
#define MAX_TMOUT_PENDING_CONNS
int dna_write_nowait(int conn_id, void *buffer, int size)
int dna_open_server(char *task, void(*read_ast)(), int *protocol, int *port, void(*error_ast)())
void id_free(int id, SRC_TYPES type)
static int is_header(int conn_id)
int tcpip_write(int conn_id, char *buffer, int size)
int Tcpip_max_io_data_write
static PENDING_OPEN Pending_conns_tmout[MAX_TMOUT_PENDING_CONNS]
DllExp DIM_NOSHARE DNA_CONNECTION * Dna_conns
int tcpip_open_client(int conn_id, char *node, char *task, int port)
int id_get(void *ptr, SRC_TYPES type)
void dim_print_date_time()
void tcpip_get_node_task(int conn_id, char *node, char *task)
static void release_conn(int conn_id)
static int ins_pend_conn(char *node, char *task, int port, SRC_TYPES src_type, int type, time_t last_used)
int tcpip_open_server(int conn_id, char *task, int *port)
int dna_start_read(int conn_id, int size)
int get_proc_name(char *proc_name)
static int find_pend_conn(char *node, char *task, int port, SRC_TYPES src_type, int type)
int get_node_name(char *node_name)
char task_name[MAX_TASK_NAME]
int tcpip_failure(int code)
sprintf(name1,"NewService%d", i)
void tcpip_set_test_write(int conn_id, int timeout)
int tcpip_open_connection(int conn_id, int path)