Changeset 24 in ntrip for trunk/ntripserver/NtripLinuxServer.c


Ignore:
Timestamp:
Jun 7, 2005, 4:47:52 PM (19 years ago)
Author:
stoecker
Message:

some UDP fixes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ntripserver/NtripLinuxServer.c

    r23 r24  
    4141 */
    4242
    43 /* $Id: NtripLinuxServer.c,v 1.11 2005/04/27 10:31:12 stoecker Exp $
     43/* $Id: NtripLinuxServer.c,v 1.12 2005/06/02 09:33:11 stoecker Exp $
    4444 * Changes - Version 0.7
    4545 * Sep 22 2003  Steffen Tschirpke <St.Tschirpke@actina.de>
     
    5959 *           - TCP sending now somewhat more stable
    6060 *           - cleanup of error handling
     61 *           - Modes may be symbolic and not only numeric
    6162 *
    6263 * Changes - Version 0.11
     
    6667 *           - cleanup of host and port handling
    6768 *           - added inactivity alarm of 60 seconds
     69 *
     70 * Changes - Version 0.12
     71 * Jun 07 2005  Dirk Stoecker <soft@dstoecker.de>
     72 *           - added UDP bindmode
    6873 */
    6974
     
    9398enum MODE { SERIAL = 1, TCPSOCKET = 2, INFILE = 3, SISNET = 4, UDPSOCKET = 5 };
    9499
    95 #define VERSION         "NTRIP NtripServerLinux/0.11"
     100#define VERSION         "NTRIP NtripServerLinux/0.12"
    96101#define BUFSZ           1024
    97102
     
    160165  const char *sisnetuser = "";
    161166  const char *initfile = NULL;
     167  int bindmode = 0;
    162168  int sock_id;
    163169  char szSendBuffer[BUFSZ];
     
    174180    exit(1);
    175181  }
    176   while((c = getopt(argc, argv, "M:i:h:b:p:s:a:m:c:H:P:f:l:u:V:")) != EOF)
     182  while((c = getopt(argc, argv, "M:i:h:b:p:s:a:m:c:H:P:f:l:u:V:B")) != EOF)
    177183  {
    178184    switch (c)
     
    194200      ttyport = optarg;
    195201      break;
     202    case 'B':
     203      bindmode = 1;
     204      break;
    196205    case 'V':
    197206      if(!strcmp("3.0", optarg)) sisnetv3 = 1;
     
    339348
    340349      memset((char *) &addr, 0x00, sizeof(addr));
    341       memcpy(&addr.sin_addr, he->h_addr, (size_t)he->h_length);
     350      if(!bindmode)
     351        memcpy(&addr.sin_addr, he->h_addr, (size_t)he->h_length);
    342352      addr.sin_family = AF_INET;
    343353      addr.sin_port = htons(inport);
    344354
    345       printf("%s input: host = %s, port = %d%s%s\n", mode == SISNET ? "sisnet"
    346         : "socket",
    347         inet_ntoa(addr.sin_addr), inport, initfile ? ", initfile = " : "",
    348         initfile ? initfile : "");
    349 
    350       if(connect(gpsfd, (struct sockaddr *) &addr, sizeof(addr)) < 0)
     355      printf("%s input: host = %s, port = %d%s%s%s\n", mode == SISNET ? "sisnet"
     356        : mode == TCPSOCKET ? "tcp socket" : "udp socket",
     357        bindmode ? "127.0.0.1" : inet_ntoa(addr.sin_addr), inport,
     358        initfile ? ", initfile = " : "",
     359        initfile ? initfile : "", bindmode ? " binding mode" : "");
     360
     361      if(bindmode)
     362      {
     363        if(bind(gpsfd, (struct sockaddr *) &addr, sizeof(addr)) < 0)
     364        {
     365          fprintf(stderr, "ERROR: can't bind input to port %d\n", inport);
     366          exit(1);
     367        }
     368      }
     369      else if(connect(gpsfd, (struct sockaddr *) &addr, sizeof(addr)) < 0)
    351370      {
    352371        fprintf(stderr, "ERROR: can't connect input to %s at port %d\n",
     
    484503      exit(0);
    485504    }
    486     printf("connection succesfull\n");
     505    printf("connection successfull\n");
    487506    send_receive_loop(sock_id, gpsfd, mode == SISNET);
    488507  }
     
    723742  fprintf(stderr, "    -H hostname of TCP server (default: %s)\n", SERV_HOST_ADDR);
    724743  fprintf(stderr, "    -f initfile send to server\n");
     744  fprintf(stderr, "    -B bindmode (bind to incoming UDP stream)\n");
    725745  fprintf(stderr, "  Mode = sisnet:\n");
    726746  fprintf(stderr, "    -P receiver port (default: %d)\n", SISNET_PORT);
Note: See TracChangeset for help on using the changeset viewer.