[Info-vax] Accuweather new contract
johnson.eric at gmail.com
johnson.eric at gmail.com
Tue Mar 31 19:35:40 EDT 2015
On Monday, March 30, 2015 at 8:41:45 PM UTC-4, johnso... at gmail.com wrote:
> I don't have the original code, but I can whip up another one pretty soon.
> It's a pretty short program so I'll post it here and others can run on their
> own gear if they like.
I only have access to Linux right now so no guarantees if this compiles on VMS.
This will create a UDP socket, and blast 100,000 packets to 1.1.1.1.1 at port 12345.
The packets are very small. Clearly there is room for improvement.
Does it compile on VMS? Does it run? How long does it take?
#include <stdio.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <string.h>
#include <unistd.h>
int main(int argc, char **argv) {
int socket_fd=0;
int bytes_sent=0;
struct sockaddr_in src;
struct sockaddr_in dest;
memset(&src,0,sizeof(src));
memset(&dest,0,sizeof(dest));
/* Create the socket */
socket_fd = socket(AF_INET, SOCK_DGRAM, 0);
if (socket_fd==-1) {
perror("Failed to create the socket");
return 0;
}
/* Bind it to anything local */
src.sin_family = AF_INET;
src.sin_addr.s_addr = htonl(INADDR_ANY);
src.sin_port = htons(12345);
if (bind(socket_fd,(struct sockaddr *)&src, sizeof(src))==-1) {
perror("Failed to bind the socket");
return 0;
}
/* Now we compose a fake destination */
dest.sin_family = AF_INET;
src.sin_addr.s_addr = 0x01010101;
src.sin_port = htons(12345);
/* Just start blasting */
for(int i=0;i<1000000;++i) {
bytes_sent+=sendto(socket_fd,"hello world",10,0,
(struct sockaddr *)&src,sizeof(src));
}
printf("Bytes sent:%d\n",bytes_sent);
}
More information about the Info-vax
mailing list