From: hackbard Date: Thu, 17 Oct 2002 14:56:17 +0000 (+0000) Subject: datagram added X-Git-Url: https://hackdaworld.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e1b1bb6bffa1e8975f0198f4f2a45fc0e1dd9464;p=my-code%2Fivac.git datagram added --- diff --git a/Makefile b/Makefile index e7383f4..9d58c28 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,7 @@ INCLUDEDIR = /usr/include CFLAGS = -O3 -Wall -OBJS = stream receive +OBJS = stream receive datagram all: $(OBJS) diff --git a/datagram.c b/datagram.c index a140c32..75a8d2e 100644 --- a/datagram.c +++ b/datagram.c @@ -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 \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); diff --git a/receive.c b/receive.c index ba61d5d..36f8ffd 100644 --- 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) {