Browse Source

Changed filename to use microseconds in file name to exclude overlap in

high-connect count events
master
Christopher Ramey 9 years ago
committed by cdramey
parent
commit
f0eb88af14
  1. 17
      src/wstationd.c

17
src/wstationd.c

@ -9,6 +9,7 @@
#include <sys/select.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/time.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <libgen.h>
@ -180,16 +181,18 @@ int main(int argc, char *argv[])
// Collect the time of the connection, process it into
// a short string
time_t timeraw = time(NULL);
struct tm* timeptr = localtime(&timeraw);
char timebuff[15];
strftime(&timebuff[0], 15, "%Y%m%d%H%M%S", timeptr);
struct timeval tvtime;
gettimeofday(&tvtime, NULL);
struct tm* timeptr = localtime(&tvtime.tv_sec);
char timebuff[20];
strftime(&timebuff[0], 20, "%Y%m%d%H%M%S", timeptr);
// Take the short date/time connection string and add the client address
// to create a filename
char fnbuff[35];
snprintf(&fnbuff[0], 34, "%s-%s.dat",
timebuff, inet_ntoa(client.sin_addr)
char fnbuff[50];
snprintf(&fnbuff[0], 50, "%s.%ld-%s.dat",
timebuff, tvtime.tv_usec,
inet_ntoa(client.sin_addr)
);
// Open a file to dump our data to

Loading…
Cancel
Save