137 lines
3 KiB
Text
137 lines
3 KiB
Text
--- ttcp.c.orig Thu Mar 29 11:41:47 2001
|
|
+++ ttcp.c Thu Mar 29 11:49:06 2001
|
|
@@ -55,6 +55,9 @@
|
|
#include <arpa/inet.h>
|
|
#include <netdb.h>
|
|
#include <sys/time.h> /* struct timeval */
|
|
+#include <unistd.h>
|
|
+#include <string.h>
|
|
+#include <stdlib.h>
|
|
|
|
#if defined(SYSV)
|
|
#include <sys/times.h>
|
|
@@ -133,7 +136,7 @@
|
|
|
|
void err();
|
|
void mes();
|
|
-int pattern();
|
|
+void pattern();
|
|
void prep_timer();
|
|
double read_timer();
|
|
int Nread();
|
|
@@ -147,6 +150,7 @@
|
|
{
|
|
}
|
|
|
|
+int
|
|
main(argc,argv)
|
|
int argc;
|
|
char **argv;
|
|
@@ -285,7 +289,7 @@
|
|
err("socket");
|
|
mes("socket");
|
|
|
|
- if (bind(fd, &sinme, sizeof(sinme)) < 0)
|
|
+ if (bind(fd, (struct sockaddr*)&sinme, sizeof(sinme)) < 0)
|
|
err("bind");
|
|
|
|
#if defined(SO_SNDBUF) || defined(SO_RCVBUF)
|
|
@@ -326,7 +330,7 @@
|
|
mes("nodelay");
|
|
}
|
|
#endif
|
|
- if(connect(fd, &sinhim, sizeof(sinhim) ) < 0)
|
|
+ if(connect(fd, (struct sockaddr*)&sinhim, sizeof(sinhim) ) < 0)
|
|
err("connect");
|
|
mes("connect");
|
|
} else {
|
|
@@ -348,11 +352,11 @@
|
|
}
|
|
fromlen = sizeof(frominet);
|
|
domain = AF_INET;
|
|
- if((fd=accept(fd, &frominet, &fromlen) ) < 0)
|
|
+ if((fd=accept(fd, (struct sockaddr*)&frominet, &fromlen) ) < 0)
|
|
err("accept");
|
|
{ struct sockaddr_in peer;
|
|
int peerlen = sizeof(peer);
|
|
- if (getpeername(fd, (struct sockaddr_in *) &peer,
|
|
+ if (getpeername(fd, (struct sockaddr*) &peer,
|
|
&peerlen) < 0) {
|
|
err("getpeername");
|
|
}
|
|
@@ -459,6 +463,7 @@
|
|
fprintf(stderr,"ttcp%s: %s\n", trans?"-t":"-r", s);
|
|
}
|
|
|
|
+void
|
|
pattern( cp, cnt )
|
|
register char *cp;
|
|
register int cnt;
|
|
@@ -614,13 +619,13 @@
|
|
|
|
case 'U':
|
|
tvsub(&tdiff, &r1->ru_utime, &r0->ru_utime);
|
|
- sprintf(outp,"%d.%01d", tdiff.tv_sec, tdiff.tv_usec/100000);
|
|
+ sprintf(outp,"%ld.%01d", tdiff.tv_sec, tdiff.tv_usec/100000);
|
|
END(outp);
|
|
break;
|
|
|
|
case 'S':
|
|
tvsub(&tdiff, &r1->ru_stime, &r0->ru_stime);
|
|
- sprintf(outp,"%d.%01d", tdiff.tv_sec, tdiff.tv_usec/100000);
|
|
+ sprintf(outp,"%ld.%01d", tdiff.tv_sec, tdiff.tv_usec/100000);
|
|
END(outp);
|
|
break;
|
|
|
|
@@ -684,7 +689,7 @@
|
|
END(outp);
|
|
break;
|
|
case 'C':
|
|
- sprintf(outp,"%d+%d", r1->ru_nvcsw-r0->ru_nvcsw,
|
|
+ sprintf(outp,"%ld+%ld", r1->ru_nvcsw-r0->ru_nvcsw,
|
|
r1->ru_nivcsw-r0->ru_nivcsw );
|
|
END(outp);
|
|
break;
|
|
@@ -743,6 +748,7 @@
|
|
/*
|
|
* N R E A D
|
|
*/
|
|
+int
|
|
Nread( fd, buf, count )
|
|
int fd;
|
|
void *buf;
|
|
@@ -752,7 +758,7 @@
|
|
int len = sizeof(from);
|
|
register int cnt;
|
|
if( udp ) {
|
|
- cnt = recvfrom( fd, buf, count, 0, &from, &len );
|
|
+ cnt = recvfrom( fd, buf, count, 0, (struct sockaddr *)&from, &len );
|
|
numCalls++;
|
|
} else {
|
|
if( b_flag )
|
|
@@ -774,6 +780,7 @@
|
|
/*
|
|
* N W R I T E
|
|
*/
|
|
+int
|
|
Nwrite( fd, buf, count )
|
|
int fd;
|
|
void *buf;
|
|
@@ -782,7 +789,7 @@
|
|
register int cnt;
|
|
if( udp ) {
|
|
again:
|
|
- cnt = sendto( fd, buf, count, 0, &sinhim, sizeof(sinhim) );
|
|
+ cnt = sendto( fd, buf, count, 0, (struct sockaddr *)&sinhim, sizeof(sinhim) );
|
|
numCalls++;
|
|
if( cnt<0 && errno == ENOBUFS ) {
|
|
delay(18000);
|
|
@@ -803,7 +810,7 @@
|
|
|
|
tv.tv_sec = 0;
|
|
tv.tv_usec = us;
|
|
- (void)select( 1, (char *)0, (char *)0, (char *)0, &tv );
|
|
+ (void)select( 1, NULL, NULL, NULL, &tv );
|
|
}
|
|
|
|
/*
|