Ejemplo n.º 1
0
/* -----------------------------------------------------------------
   MAIN: This is started by the IBP server in the source depot, it 
   receives as parameters name of target server, port, and readfd, 
   stablishes a connection with the server and sends the data
   ----------------------------------------------------------------- */
main (int argc, char **argv)
{
  int              *connectfds, sourcefd, numtargets, i, nargs;
  int               retval;
  unsigned long int filesize;
  double            rtmp, result;
  double            s;
  char              **targets, **ports;
  float             rate;

  fprintf(stderr,"\nTCP DATA MOVER:\n%s %s %s %s %s %s <%s>\n\n\n",
	  argv[0],argv[1],argv[2],argv[3],argv[4],argv[5],argv[6]);
 
  if(argc < 7)
    sys_error("Incorrect parameters: smclientTCP <target_hostname> <port_Number> <file_descriptor> <filesize> <numtargets> <IBP_cap>"); 
 
  sourcefd = atoi(argv[3]);  
  filesize = atol(argv[4]);
  numtargets = atoi(argv[5]);
  strcpy(glb.IBP_cap,argv[6]);

  targets = String2Array(argv[1],numtargets,MAX_HOST_LEN);
  ports = String2Array(argv[2],numtargets,MAX_WORD_LEN);
  connectfds = (int *) malloc(sizeof(int) * numtargets);

  for(i=0;i<numtargets;i++){
    if((connectfds[i]= tcp_connect(targets[i],ports[i]))<0) 
      sys_error("connectfd error: host %d failed");    
  }

  s = seconds();      
  retval = SendData2(sourcefd, connectfds, filesize, numtargets);
  if(retval<0){
    fprintf(stderr,"DM mclientTCP problem sending data\n");
    exit(TCP_FAIL);
  }
  s = seconds()-s;     
  rate = (s !=0) ? filesize/(1024.0*1024*(s)) : 0;

  fprintf(stderr,"\nTransfer time = %6.2f secs ",s);
  fprintf(stderr," size = %d   xfer rate = %.2f MB/s (%.2fMb/s)\n",
	  filesize, rate, rate*8);

  for(i=0;i<numtargets;i++)
    close(connectfds[i]);  

  free(connectfds);
  free(targets);
  free(ports);
  exit(TCP_OK);
}
Ejemplo n.º 2
0
void LoadPunct( LPTSTR lpStr)
{
	TCHAR szStrArr[70][70];
	WORD wCount,wHead;
	int i;
	
	wCount = String2Array(lpStr, (LPTSTR)szStrArr, 70);

	if( szStrArr[0][0] > _T('~') || szStrArr[0][0] < _T('!')) return;

	wHead = szStrArr[0][0] - _T('!');

	for(i = 1; i < wCount; i ++)
	{
		_tcscpy_s(aPunct[wHead][i - 1], 70, szStrArr[i]);
	}
	aPunct[wHead][wCount][0] = _T('\0');
}
Ejemplo n.º 3
0
/* -----------------------------------------------------------------
   MAIN: This is started by the IBP server in the source depot, it 
   receives as parameters name of target server, port, and readfd, 
   stablishes a connection with the server and sends the data
   ----------------------------------------------------------------- */
main (int argc, char **argv)
{
  int *connectfds, sourcefd, numtargets, i, nargs;
  int *retval, position, r;
  unsigned long int filesize;
  double rtmp, result;
  double s;
  char **targets, **ports;
  float rate;

  fprintf(stderr,"\nSERIALIZED TCP DATA MOVER:\n%s %s %s %s %s %s <%s>\n\n",
	  argv[0],argv[1],argv[2],argv[3],argv[4],argv[5],argv[6]);
 
  if(argc < 7)
    sys_error("Incorrect parameters: smclientTCP <target_hostname> <port_Number> <file_descriptor> <filesize> <numtargets> <IBP_cap>");    
 
  sourcefd = atoi(argv[3]);  
  filesize = atol(argv[4]);
  numtargets = atoi(argv[5]);
  strcpy(glb.IBP_cap,argv[6]);
  retval = (int *)malloc(sizeof(int) * numtargets);

  targets = String2Array(argv[1],numtargets,MAX_HOST_LEN);
  ports = String2Array(argv[2],numtargets,MAX_WORD_LEN);
  connectfds = (int *) malloc(sizeof(int) * numtargets);
  position = lseek(sourcefd,0,SEEK_CUR);

  for(i=0;i<numtargets;i++){
    if((connectfds[i]= tcp_connect(targets[i],ports[i]))<0) 
      sys_error("connectfd error");    
    else
      fprintf(stderr,"Target %d: Success in connectfd==%d\n",i,connectfds[i]);
  }

  for(i=0; i<numtargets; i++){
    r = lseek(sourcefd, position, SEEK_SET);
    s = seconds();  
    retval[i] = SendData2(sourcefd, connectfds[i], filesize);
    if(retval[i]<0){
      fprintf(stderr,"Target %d failed:",i);
      perror(" ");
      exit(TCP_FAIL);
    }
    else{ 
      fprintf(stderr,"\ntarget %d done\n\n",i);
      s = seconds()-s;     
      rate = (s !=0) ? filesize/(1024.0*1024*(s)) : 0;      
      fprintf(stderr,"\nTransfer time = %6.2f secs ",s);
      fprintf(stderr," size = %d   xfer rate = %.2f MB/s (%.2fMb/s)\n",
	      filesize, rate, rate*8);
    }
  } 

  for(i=0;i<numtargets;i++){
    close(connectfds[i]);  
  }

  free(retval);
  free(connectfds);
  free(targets);
  free(ports); 
  exit(TCP_OK);
}