Actual source code: ex42a.c
2: static char help[] = "Sends a PETSc vector to a socket connection, receives it back, within a loop. Must be run with ex42.c.\n";
4: #include <petscvec.h>
6: int main(int argc, char **args)
7: {
8: Vec b;
9: PetscViewer fd;
10: PetscInt i;
12: PetscFunctionBeginUser;
13: PetscCall(PetscInitialize(&argc, &args, (char *)0, help));
14: /* server indicates we WAIT for someone to connect to our socket */
15: PetscCall(PetscViewerSocketOpen(PETSC_COMM_WORLD, "server", PETSC_DEFAULT, &fd));
17: PetscCall(VecCreateMPI(PETSC_COMM_WORLD, 10000, PETSC_DECIDE, &b));
18: for (i = 0; i < 1000; i++) {
19: PetscCall(VecView(b, fd));
20: PetscCall(VecDestroy(&b));
21: PetscCall(VecCreate(PETSC_COMM_WORLD, &b));
22: PetscCall(VecLoad(b, fd));
23: }
24: PetscCall(VecDestroy(&b));
25: PetscCall(PetscViewerDestroy(&fd));
26: PetscCall(PetscFinalize());
27: return 0;
28: }