EasyManua.ls Logo

ChamSys MagicQ - Page 271

ChamSys MagicQ
328 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
ChamSys Ltd www.chamsys.co.uk
MagicQ User Manual 271 Version 1.4.9.0
getsockopt (remote_ether_sock,SOL_SOCKET,SO_REUSEADDR, opts, &optlen);
opts[0] = 1;
setsockopt (remote_ether_sock,SOL_SOCKET,SO_REUSEADDR, opts, optlen);
/* Give the socket a name. */
name.sin_family = AF_INET;
name.sin_port = htons (REMOTE_ETHER_PORT);
name.sin_addr.s_addr = htonl (INADDR_ANY);
if (bind (remote_ether_sock, (struct sockaddr *) &name, sizeof (name)) < 0)
{
closesocket(remote_ether_sock);
return (FALSE);
}
getsockopt (remote_ether_sock,SOL_SOCKET,SO_BROADCAST, opts, &optlen);
opts[0] = 1;
setsockopt (remote_ether_sock,SOL_SOCKET,SO_BROADCAST, opts, optlen);
{
u_long block;
block = 1;
ioctlsocket(remote_ether_sock,FIONBIO,&block);
}
return TRUE;
}
int remote_ether_rx(char *data, word16 size)
{
char message[MAX_CREP_MSG];
int nbytes;
remote_ether_message_t *rem = (remote_ether_message_t *) message;
struct sockaddr_in name;
int name_len = sizeof(name);
if (!remote_ether_sock) return (0);
nbytes = recvfrom (remote_ether_sock, message, MAX_CREP_MSG, 0, (struct
sockaddr *) &name, &name_len);
if (nbytes > 0)
{
if (rem->chamsys == (('C'<<24)|('R'<<16)|('E'<<8)|('P')))
{
int len = wswap(rem->length);
remote_ether_bkwd = rem->seq_fwd;
if (len<(MAX_CREP_MSG-(sizeof(remote_ether_message_t)+1)))
{
if (len>size) len = size;
memcpy(data,&(rem->data),len);
return (len);
}
}
}
return (0);
}
char remote_ether_tx(char *data, word16 size)
{
// Format the message

Table of Contents

Other manuals for ChamSys MagicQ

Related product manuals