Actual source code: ex42a.c

  2: static char help[] = "Sends a PETSc vector to a socket connection, receives it back, within a loop. Works with ex42.c.\n";

 4:  #include petscvec.h

  8: int main(int argc,char **args)
  9: {
 10:   Vec            b;
 11:   PetscViewer    fd;
 13:   PetscInt       i;

 15:   PetscInitialize(&argc,&args,(char *)0,help);
 16:   /* server indicates we WAIT for someone to connect to our socket */
 17:   PetscViewerSocketOpen(PETSC_COMM_WORLD,"server",PETSC_DEFAULT,&fd);

 19:   VecCreateMPI(PETSC_COMM_WORLD,10000,PETSC_DECIDE,&b);
 20:   for (i=0;i<1000;i++){
 21:     VecView(b,fd);
 22:     VecDestroy(b);
 23:     VecLoad(fd,VECMPI,&b);
 24:   }
 25:   VecDestroy(b);
 26:   PetscFinalize();
 27:   return 0;
 28: }