FACT++  1.0
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 
)

Definition at line 733 of file dna.c.

References DNA_CONNECTION::buffer, DNA_CONNECTION::buffer_size, DNA_NET::code, conn_free(), conn_get(), DIM_ERROR, DIM_INFO, dim_print_date_time(), DIMDNSCNERR, DIMDNSCNEST, DIMTCPCNERR, DIMTCPCNEST, dna_close(), Dna_conns, dna_init(), dna_report_error(), dna_start_read(), dna_write_nowait(), DNA_CONNECTION::error_ast, FALSE, find_pend_conn(), get_node_name(), get_proc_name(), id, ins_pend_conn(), Memory::malloc(), Net_conns, DNA_NET::node, OPN_MAGIC, DNA_CONNECTION::protocol, RD_HDR, DNA_CONNECTION::read_ast, READ_HEADER_SIZE, rel_pend_conn(), DNA_CONNECTION::saw_init, sprintf(), SRC_DIC, SRC_DIS, STA_CONN, DNA_CONNECTION::state, str, DNA_NET::task, TCP_RCV_BUF_SIZE, TCPIP, tcpip_close(), tcpip_failure(), tcpip_open_client(), TRUE, and DNA_CONNECTION::writing.

Referenced by handle_dns_info(), open_dns(), retry_dns_connection(), and web_open_server().

735 {
736  register DNA_CONNECTION *dna_connp;
737  char str[256];
738  register int tcpip_code, conn_id, id;
739  DNA_NET local_buffer;
740  extern int get_proc_name(char *);
741  char src_type_str[64];
742 
743  if(server_protocol){}
744  dna_init();
745 /*
746  if(!DNA_Initialized) {
747  conn_arr_create(SRC_DNA);
748  DNA_Initialized = TRUE;
749  }
750 */
751  conn_id = conn_get();
752  dna_connp = &Dna_conns[conn_id] ;
753 /*
754  if( !(conn_id = conn_get()) )
755  dim_panic("In dna_open_client: No more connections\n");
756 */
757  dna_connp->protocol = TCPIP;
758  dna_connp->error_ast = error_ast;
759  tcpip_code = tcpip_open_client(conn_id, server_node, server_task, port);
760  if( tcpip_failure(tcpip_code) )
761  {
762 #ifdef VMS
763  if(!strstr(server_node,"fidel"))
764  {
765 #endif
766  if(!find_pend_conn(server_node, server_task, port, src_type, 0))
767  {
768  if(src_type == SRC_DIS)
769  strcpy(src_type_str,"Server");
770  else if(src_type == SRC_DIC)
771  strcpy(src_type_str,"Client");
772  else
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"))
777  dna_report_error( conn_id, tcpip_code, str, DIM_ERROR, DIMDNSCNERR );
778  else
779  dna_report_error( conn_id, tcpip_code, str, DIM_ERROR, DIMTCPCNERR );
780  ins_pend_conn(server_node, server_task, port, src_type, 0, 0);
781  }
782 #ifdef VMS
783  }
784 #endif
785  tcpip_close(conn_id);
786  conn_free( conn_id );
787  return(0);
788  }
789  if( (id = find_pend_conn(server_node, server_task, port, src_type, 0)) )
790  {
791  if(src_type == SRC_DIS)
792  strcpy(src_type_str,"Server");
793  else if(src_type == SRC_DIC)
794  strcpy(src_type_str,"Client");
795  else
796  strcpy(src_type_str,"Unknown type");
797  sprintf( str,"%s Connection established to", src_type_str);
798  if(!strcmp(server_task,"DIM_DNS"))
799  dna_report_error( conn_id, -1, str, DIM_INFO, DIMDNSCNEST );
800  else
801  dna_report_error( conn_id, -1, str, DIM_INFO, DIMTCPCNEST );
802  rel_pend_conn(id, 0);
803  }
804  dna_connp->state = RD_HDR;
805  dna_connp->writing = FALSE;
806  dna_connp->buffer = (int *)malloc((size_t)TCP_RCV_BUF_SIZE);
807 /*
808  if(!dna_connp->buffer)
809  {
810  printf("Error in DNA - open_client malloc returned 0\n");
811  fflush(stdout);
812  }
813 */
814  dna_connp->buffer_size = TCP_RCV_BUF_SIZE;
815  dna_connp->read_ast = read_ast;
816  dna_connp->saw_init = TRUE; /* we send it! */
818  local_buffer.code = (int)htovl(OPN_MAGIC);
819  get_node_name(local_buffer.node);
820  get_proc_name(local_buffer.task);
821  tcpip_code = dna_write_nowait(conn_id, &local_buffer, sizeof(local_buffer));
822  if (tcpip_failure(tcpip_code))
823  {
825  printf(" Client Establishing Connection: Couldn't write to Conn %3d : Server %s@%s\n",conn_id,
826  Net_conns[conn_id].task, Net_conns[conn_id].node);
827  fflush(stdout);
828  dna_close(conn_id);
829  return(0);
830  }
831  read_ast(conn_id, NULL, 0, STA_CONN);
832  return(conn_id);
833 }
static void rel_pend_conn(int id, int type)
Definition: dna.c:717
Definition: dns.c:26
#define DIMDNSCNERR
Definition: dim_common.h:301
int protocol
Definition: dim.h:389
#define READ_HEADER_SIZE
Definition: dna.c:21
DllExp DIM_NOSHARE NET_CONNECTION * Net_conns
Definition: conn_handler.c:32
#define TCPIP
Definition: dim.h:194
#define TRUE
Definition: dim.h:135
char str[80]
Definition: test_client.c:7
#define DIMTCPCNEST
Definition: dim_common.h:299
#define OPN_MAGIC
Definition: dim.h:208
#define FALSE
Definition: dim.h:136
int dna_close(int conn_id)
Definition: dna.c:835
void conn_free(int conn_id)
Definition: conn_handler.c:118
void * malloc()
Definition: EventBuilder.cc:99
char id[4]
Definition: FITS.h:71
#define TCP_RCV_BUF_SIZE
Definition: dim.h:165
void(* error_ast)()
Definition: dim.h:383
CONN_STATE state
Definition: dim.h:390
#define DIMTCPCNERR
Definition: dim_common.h:298
Definition: dim.h:223
int writing
Definition: dim.h:391
#define DIMDNSCNEST
Definition: dim_common.h:302
int tcpip_close(int conn_id)
Definition: tcpip.c:1510
void dna_report_error(int conn_id, int code, char *routine_name, int severity, int errcode)
Definition: dna.c:903
int dna_write_nowait(int conn_id, void *buffer, int size)
Definition: dna.c:412
int saw_init
Definition: dim.h:392
DllExp DIM_NOSHARE DNA_CONNECTION * Dna_conns
Definition: conn_handler.c:31
int tcpip_open_client(int conn_id, char *node, char *task, int port)
Definition: tcpip.c:1014
int dna_init()
Definition: dna.c:530
void dim_print_date_time()
Definition: utilities.c:134
static int ins_pend_conn(char *node, char *task, int port, SRC_TYPES src_type, int type, time_t last_used)
Definition: dna.c:620
int * buffer
Definition: dim.h:384
Definition: dim.h:190
int dna_start_read(int conn_id, int size)
Definition: dna.c:234
int get_proc_name(char *proc_name)
Definition: utilities.c:22
static int find_pend_conn(char *node, char *task, int port, SRC_TYPES src_type, int type)
Definition: dna.c:675
int buffer_size
Definition: dim.h:385
int get_node_name(char *node_name)
Definition: utilities.c:33
int code
Definition: dim.h:224
char task[MAX_TASK_NAME]
Definition: dim.h:226
int tcpip_failure(int code)
Definition: tcpip.c:1540
void(* read_ast)()
Definition: dim.h:382
sprintf(name1,"NewService%d", i)
#define STA_CONN
Definition: dim.h:199
int conn_get()
Definition: conn_handler.c:79
char node[MAX_NODE_NAME]
Definition: dim.h:225

+ Here is the call graph for this function:

+ Here is the caller graph for this function: