]> hackdaworld.org Git - my-code/ivac.git/commitdiff
datagram added
authorhackbard <hackbard>
Thu, 17 Oct 2002 14:56:17 +0000 (14:56 +0000)
committerhackbard <hackbard>
Thu, 17 Oct 2002 14:56:17 +0000 (14:56 +0000)
Makefile
datagram.c
receive.c

index e7383f4299c063d14ab4f82f58617fd3284df306..9d58c2839b9d256326df68e208f87646956b0e39 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -4,7 +4,7 @@ INCLUDEDIR = /usr/include
 
 CFLAGS = -O3 -Wall
 
-OBJS = stream receive
+OBJS = stream receive datagram
 
 all: $(OBJS)
 
index a140c32c32e9f5c439415839f8d744e0b70edd7b..75a8d2e73b346e8a8553beffffadce082de60419 100644 (file)
@@ -29,8 +29,8 @@
 int main(int argc, char *argv[]) {
   int send_fd;
   struct sockaddr_in local_addr, remote_addr;
-  socklen_t remote_addr_len;
-  int send_bytes;
+  // socklen_t remote_addr_len;
+  int send_bytes, read_bytes;
 
   if(argc!=3) {
     printf("usage: %s <target-ip/broadcast-addr> <port>\n",argv[0]);
@@ -57,14 +57,14 @@ int main(int argc, char *argv[]) {
   memset(&remote_addr,0,sizeof(remote_addr));
   remote_addr.sin_family=AF_INET;
   remote_addr.sin_port=htons(atoi(argv[2]));
-  remote_addr.sin_addr=inet_addr(argv[1]);
+  remote_addr.sin_addr.s_addr=inet_addr(argv[1]);
 
   /* send stuff .... */
   read_bytes=1;
   while(read_bytes>0) {
     unsigned char buf[1000];
     read_bytes=read(0,buf,sizeof(buf));
-    send_bytes=sendto(send_fd,buf,sizeof(buf),&remote_addr,sizeof(remote_addr);
+    send_bytes=sendto(send_fd,buf,sizeof(buf),0,&remote_addr,sizeof(remote_addr));
   }
 
   close(send_fd);
index ba61d5d816322fb4f19bdd878a21c72f1c32e941..36f8ffd770de4a8f33a9ac85b57ceddceb1fa34f 100644 (file)
--- a/receive.c
+++ b/receive.c
@@ -29,7 +29,6 @@
 int main(int argc, char *argv[]) {
   int receive_fd;
   struct sockaddr_in target_addr;
-  socklen_t target_addr_len;
   int receive_bytes, write_bytes;
 
   if(argc!=3) {