diff options
author | Ian C <ianc@noddybox.co.uk> | 2023-01-09 12:06:34 +0000 |
---|---|---|
committer | Ian C <ianc@noddybox.co.uk> | 2023-01-09 12:06:34 +0000 |
commit | 695b72c4ebdbf8f61284bb195ebf978f45ac1da9 (patch) | |
tree | d687cb0dac7556497b484acc114a8f3b5564e44f /serv.c | |
parent | 68a2fb5d0061626718f63daec7cf5a42a42722a9 (diff) |
Updated serv for a switch to just ASCII dump the comms.
Diffstat (limited to 'serv.c')
-rw-r--r-- | serv.c | 21 |
1 files changed, 16 insertions, 5 deletions
@@ -96,20 +96,23 @@ static void Dump(const char *p, int len) int main(int argc, char *argv[]) { struct sockaddr_in addr; - char buff[1024]; + char buff[1025]; int len; socklen_t addrlen; int sock_fd; int connect_fd; + int ascii = 0; name=argv[0]; - if (argc!=2) + if (argc<2) { - fprintf(stderr,"%s: usage %s port\n", name, name); + fprintf(stderr,"%s: usage %s port [-a]\n", name, name); exit(1); } + ascii = (argc == 3 && strcmp(argv[2], "-a") == 0); + sock_fd = Socket((short)atoi(argv[1])); printf("%s: socket bound\n",name); @@ -145,8 +148,16 @@ int main(int argc, char *argv[]) while((len=read(connect_fd,buff,1024))>0) { buff[len]=0; - printf("%s: recieved\n",name); - Dump(buff, len); + + if (ascii) + { + printf("%s", buff); + } + else + { + printf("%s: recieved\n",name); + Dump(buff, len); + } } if (len == -1) |