00001
00002 #ifndef _1DARRAY_H
00003 #define _1DARRAY_H
00004
00005 #include "myendian.h"
00006 #include "remotesocket.h"
00007
00008 template <class Etype>
00009 inline int RemoteSocket::SendArray1D(Etype *a, int n1)
00010 {
00011 static int elemsize = sizeof(Etype);
00012 int totsize = elemsize*n1;
00013 unsigned char *data;
00014 ALLOC1D(&data, totsize);
00015 int ptr = 0;
00016
00017 memcpy(&data[ptr], &a[0], totsize);
00018 ptr += totsize;
00019
00020 setByteOrder(data, totsize, elemsize);
00021 SendBytes(totsize, data);
00022 FREE1D(&data, totsize);
00023
00024 return 0;
00025 }
00026
00027 template <class Etype>
00028 inline int RemoteSocket::RecvArray1D(Etype *a, int n1)
00029 {
00030 static int elemsize = sizeof(Etype);
00031 int totsize = elemsize*n1;
00032 unsigned char *data;
00033 ALLOC1D(&data, totsize);
00034 int ptr = 0;
00035
00036 RecvBytes(totsize, data);
00037 setByteOrder(data, totsize, elemsize);
00038
00039 memcpy(&a[0], &data[ptr], totsize);
00040 ptr += totsize;
00041
00042 FREE1D(&data, totsize);
00043
00044 return 0;
00045 }
00046
00047 #endif // _1DARRAY_H
00048