From c1a1784c9f5a71f591d14d3e61571b7055c18e53 Mon Sep 17 00:00:00 2001 From: hackbard Date: Sat, 19 Oct 2002 02:08:09 +0000 Subject: [PATCH] udp buggy! --- Makefile | 2 +- datagram.c | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 8076296..0924a8b 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ INCLUDEDIR = /usr/include -CFLAGS = -O3 -Wall +CFLAGS = -DDEBUG -O3 -Wall OBJS = stream receive datagram dgramrcv diff --git a/datagram.c b/datagram.c index c288482..2637fa8 100644 --- a/datagram.c +++ b/datagram.c @@ -48,7 +48,9 @@ int main(int argc, char *argv[]) { } optlen=1; - setsockopt(send_fd,SOL_SOCKET,SO_BROADCAST,NULL,optlen); + if((setsockopt(send_fd,SOL_SOCKET,SO_BROADCAST,NULL,optlen))==-1) + perror("setsockopt"); + memset(&local_addr,0,sizeof(local_addr)); local_addr.sin_family=AF_INET; @@ -78,6 +80,10 @@ int main(int argc, char *argv[]) { unsigned char buf[1000]; read_bytes=read(0,buf,sizeof(buf)); send_bytes=sendto(send_fd,buf,read_bytes,0,(struct sockaddr *)&remote_addr,remote_addr_len); +#ifdef DEBUG + perror("sendto"); +#endif + fwrite(buf,read_bytes,1,cmd_fd); } -- 2.39.2