1 | /* |
---|
2 | send-vec.c - simple client process |
---|
3 | */ |
---|
4 | |
---|
5 | #include <fcntl.h> |
---|
6 | #include "MP.h" |
---|
7 | #include "gmp.h" |
---|
8 | |
---|
9 | main(argc, argv) |
---|
10 | int argc; |
---|
11 | char *argv[]; |
---|
12 | { |
---|
13 | char *ifname = NULL; |
---|
14 | MP_Link_pt link = NULL; |
---|
15 | MP_Env_pt env = NULL; |
---|
16 | int i; |
---|
17 | float fvec[5]; |
---|
18 | double dvec[5]; |
---|
19 | long intvec[5]; |
---|
20 | |
---|
21 | fvec[0] = 0.0; fvec[1] = 1.0; fvec[2] = 2.0; fvec[3] = 3.0; fvec[4] = 4.0; |
---|
22 | dvec[0] = 0.0; dvec[1] = 1.0; dvec[2] = 2.0; dvec[3] = 3.0; dvec[4] = 4.0; |
---|
23 | intvec[0] = 0; intvec[1] = 1; intvec[2] = 2; intvec[3] = 3; intvec[4] = 4; |
---|
24 | |
---|
25 | env = MP_InitializeEnv(NULL); |
---|
26 | if (env == NULL) { |
---|
27 | fprintf(stderr, "%s: MP_InitializeEnv() failed!\n", argv[0]); |
---|
28 | exit(1); |
---|
29 | } |
---|
30 | |
---|
31 | if ((link = MP_OpenLink(env, argc, argv)) == NULL) { |
---|
32 | fprintf(stderr, "%s: MP_OpenLink() failed!\n", argv[0]); |
---|
33 | exit(1); |
---|
34 | } |
---|
35 | |
---|
36 | MP_SetLinkOption(link, MP_LINK_LOG_MASK_OPT, MP_LOG_INIT_EVENTS); |
---|
37 | MP_SetLinkOption(link, MP_LINK_LOG_MASK_OPT, MP_LOG_WRITE_EVENTS); |
---|
38 | MP_SetLinkOption(link, MP_LINK_LOG_MASK_OPT, MP_LOG_READ_EVENTS); |
---|
39 | |
---|
40 | printf("\n\nSEND-VEC: putting the vectors now\n\n"); |
---|
41 | |
---|
42 | IMP_PutBytes(link, (char *)&fvec[0], 20); |
---|
43 | |
---|
44 | for (i = 0; i < 5; i++) |
---|
45 | if (IMP_PutLong(link, (long *)&fvec[i]) != MP_Success) |
---|
46 | printf("couldn't do the putlongs !!\n"); |
---|
47 | MP_EndMsgReset(link); |
---|
48 | |
---|
49 | fprintf(stderr,"Now calling IMP_PutBasicVector()\n");fflush(stderr); |
---|
50 | |
---|
51 | if (IMP_PutBasicVector(link, intvec, MP_Sint32Type, 5) != MP_Success){ |
---|
52 | printf("couldn't put the int vector!!\n"); |
---|
53 | MP_PrintError(link); |
---|
54 | } |
---|
55 | else |
---|
56 | printf("SEND-VEC: Successfully put the int vector!!\n"); |
---|
57 | |
---|
58 | if (IMP_PutBasicVector(link, fvec, MP_Real32Type, 5) != MP_Success) |
---|
59 | printf("couldn't put the float vector!!\n"); |
---|
60 | else |
---|
61 | printf("Successfully put the float vector!!\n"); |
---|
62 | |
---|
63 | if (IMP_PutBasicVector(link, dvec, MP_Real64Type, 5) != MP_Success) |
---|
64 | printf("couldn't put the double vector!!\n"); |
---|
65 | else |
---|
66 | printf("Successfully put the double vector!!\n"); |
---|
67 | MP_EndMsgReset(link); |
---|
68 | |
---|
69 | if (IMP_PutSint32Vector(link, intvec, 5) != MP_Success) |
---|
70 | printf("couldn't put the int vector!!\n"); |
---|
71 | else |
---|
72 | printf("Successfully put the int vector!!\n"); |
---|
73 | |
---|
74 | if (IMP_PutReal32Vector(link, fvec, 5) != MP_Success) |
---|
75 | printf("couldn't put the float vector!!\n"); |
---|
76 | else |
---|
77 | printf("Successfully put the float vector!!\n"); |
---|
78 | |
---|
79 | if (IMP_PutReal64Vector(link, dvec, 5) != MP_Success) |
---|
80 | printf("couldn't put the double vector!!\n"); |
---|
81 | else |
---|
82 | printf("Successfully put the double vector!!\n"); |
---|
83 | MP_EndMsgReset(link); |
---|
84 | |
---|
85 | MP_CloseLink(link); |
---|
86 | MP_ReleaseEnv(env); |
---|
87 | } |
---|