16 static void swap4(
char *data,
int ndata) {
22 for (i=0; i<ndata; i+=4) {
25 dataptr[0] = dataptr[3];
26 dataptr[1] = dataptr[2];
80 }
else if (nread == 0)
135 header.
length = IMDVersion;
149 std::vector<char> data;
150 data.push_back(static_cast<char>(info->
time_switch));
152 data.push_back(static_cast<char>(info->
box_switch));
154 data.push_back(static_cast<char>(info->
wrap_switch));
163 char *buf =
new char[size];
165 memcpy((
void *)(buf+
HEADERSIZE), (
const void *)(infoData.data()), infoData.size()*
sizeof(char));
173 char *buf =
new char[size];
175 memcpy((
void *)(buf+
HEADERSIZE), (
const void *)indices, 4*n);
176 memcpy((
void *)(buf+
HEADERSIZE+4*n), (
const void *)forces, 12*n);
184 char *buf =
new char[size];
194 char *buf =
new char[size];
204 char *buf =
new char[size];
206 memcpy((
void *)(buf+
HEADERSIZE), (
const void *)vels, 3*n*
sizeof(
float));
214 char *buf =
new char[size];
216 memcpy((
void *)(buf+
HEADERSIZE), (
const void *)forces, 3*n*
sizeof(
float));
224 char *buf =
new char[size];
234 char *buf =
new char[size];
248 *length = header.length;
267 swap4((
char *)&buf, 4);
281 char *ch = (
char*)(&header);
283 *length = header.length;
288 if (
imd_readn(s, (
char *)indices, 4*n) != 4*n)
return 1;
289 if (
imd_readn(s, (
char *)forces, 12*n) != 12*n)
return 1;
303 return (
imd_readn(s, (
char *)vels, 12*n) != 12*n);
307 return (
imd_readn(s, (
char *)forces, 12*n) != 12*n);
static int32 imd_writen(void *s, const char *ptr, int32 n)
static void fill_header(IMDheader *header, IMDType type, int32 length)
int imd_send_mdcomm(void *s, int32 n, const int32 *indices, const float *forces)
int vmdsock_selread(void *v, int sec)
IMDType imd_recv_header_nolengthswap(void *s, int32 *length)
structure used to perform byte swapping operations
int imd_send_energies(void *s, const IMDEnergies *energies)
int imd_recv_forces(void *s, int32 n, float *forces)
int imd_recv_time(void *s, IMDTime *time)
int imd_send_box(void *s, const IMDBox *box)
static int32 imd_ntohl(int32 n)
static void swap4(char *data, int ndata)
int imd_trate(void *s, int32 rate)
static int32 imd_htonl(int32 h)
int imd_send_fcoords(void *s, int32 n, const float *coords)
int imd_recv_velocities(void *s, int32 n, float *vels)
static void swap_header(IMDheader *header)
int imd_send_forces(void *s, int32 n, const float *forces)
int imd_recv_fcoords(void *s, int32 n, float *coords)
int imd_send_time(void *s, const IMDTime *time)
int imd_recv_mdcomm(void *s, int32 n, int32 *indices, float *forces)
int imd_sessioninfo(void *s, const IMDSessionInfo *info)
static int32 imd_readn(void *s, char *ptr, int32 n)
int imd_handshake(void *s, const int IMDVersion)
int imd_disconnect(void *s)
std::vector< char > toTypeVector(const IMDSessionInfo *info)
int imd_recv_handshake(void *s)
Receive header and data.
int vmdsock_write(void *v, const void *buf, int len)
int imd_recv_energies(void *s, IMDEnergies *energies)
IMDType imd_recv_header(void *s, int32 *length)
int imd_recv_box(void *s, IMDBox *box)
int vmdsock_read(void *v, void *buf, int len)
int imd_send_velocities(void *s, int32 n, const float *vels)