Hi All,

Linrad will again have a network. A master computer, 
one that receives its signal from its own hardware while
using its own calibration functions will send data 
to the network (if enabled) in one of several formats.

Thanks to Xtof, ON4IY, I have suitable code that reliably
sends UDP packages that can be picked up by any number of
computers on the network.

Linrad contains a server when running as a master. This
server listens to the network like this:
setup()
  {
  memset(&slave_addr,0,sizeof(slave_addr));
  slave_addr.sin_family = AF_INET;
  slave_addr.sin_addr.s_addr = htonl(INADDR_ANY);
  slave_addr.sin_port = htons(CONNPORT);
  if( (netfd.any_slave = socket(AF_INET, SOCK_STREAM, 0)) < 0)
    {
    lirerr(1249);
    return;
    }
  bind(netfd.any_slave, (struct sockaddr *)&slave_addr, sizeof(slave_addr));
  listen(netfd.any_slave, 5);
  FD_ZERO(&master_readfds);
  FD_SET(netfd.any_slave, &master_readfds);
  }
server()
.
.
.
testfds=master_readfds;
if( select(FD_SETSIZE, &testfds, (fd_set *)0, (fd_set *)0, &timeout) > 0)
  {
  for(fd = 0; fd < FD_SETSIZE; fd++)
    {
    if(FD_ISSET(fd,&testfds))
      {
      if(fd == netfd.any_slave)
        {
        if(no_of_netslaves == MAX_NETSLAVES)
          {
          lirerr(1270);
          goto netserver_error_exit;
          }
        client_len = sizeof(client_address);
        client_sockfd = accept(netfd.any_slave,
                   (struct sockaddr *)&client_address, (void*)&client_len);
        FD_SET(client_sockfd, &master_readfds);
        netfd.slaves[no_of_netslaves]=client_sockfd;
        no_of_netslaves++;
        ip=(void*)&client_address.sin_addr.s_addr;
        sprintf(s,"adding client [%d]  %d.%d.%d.%d on fd %d",
                 no_of_netslaves, ip[0], ip[1], ip[2], ip[3] , client_sockfd);
 
.
.
.

from what I can read in man pages this should give sockets SOCK_STREAM
(Provides  sequenced,  reliable,  two-way,   connection-based   byte
streams.   An  out-of-band  data transmission mechanism may be supported.)

In real life it does not work too well. Not on elderly computers.
It is ok on Pentium III and above, but it doers not work
on Pentium MMX or Pentium I when the CPU load is above about 50%.
(Sending UDP is fine, but SOCK_STREAM is not)

I have tried to split data in small packages (1500 bytes) while
using select to make sure I am allowed to write to the socket.
It does not matter whether I use write or send, when computers
are under heavu load packets are lost occasionally. 

>From the documentation I infer that the protocol takes care of 
hand-shaking and resending: "reliable, two-way, connection-based
byte streams." 

I could solve this problem by adding my own hand-shaking. The
purpose of the SOCK_STREAM connection is to allow a slave to ask 
the master for calibration functions and also for the slave
to tell the master what frequency he is currently listening to.
There may be other things one would like to send in a reliable
but totally time-uncritical fashion.

Presumably I have misunderstood something. Any comments?

73

Leif  /  SM5BSZ



#############################################################
This message is sent to you because you are subscribed to
  the mailing list <linrad@antennspecialisten.se>.
To unsubscribe, E-mail to: <[EMAIL PROTECTED]>
To switch to the DIGEST mode, E-mail to <[EMAIL PROTECTED]>
To switch to the INDEX mode, E-mail to <[EMAIL PROTECTED]>
Send administrative queries to  <[EMAIL PROTECTED]>

Reply via email to