Proxima ASA 7911, 7910 manual name.sinfamily= AFINET

Models: 7911 7910

1 127
Download 127 pages 54.08 Kb
Page 105
Image 105
55name.sin_family= AF_INET;

55name.sin_family= AF_INET;

56/* htons() converts a 16-bit integer from host to network byte order */

57name.sin_port= htons(atoi(argv[2]));

58

59/* Construct message, including Serial Adapter header. */

60buf[0]= DATA1;

61buf[3]= 0x1b;

62dataLength= strlen(DATA);

63networkDataLength= htons(dataLength);

64memcpy(&buf[1], (char *)&networkDataLength, sizeof(short));

65strcpy(&buf[4], DATA);

66printf(“%s\n”, &buf[4]);

67

68/* Repeatedly send message to serial adapter */

69for(i=0; i< 10; i++)

70{

71sleep(1);

72/* Sendto() parameters:

731. Local socket which will handle the data.

742. Pointer to buffer containing data to be sent.

753. Number of bytes of data to be sent.

764. Flags (ex. MSG_OOB for TCP urgent data)

775. Destination IP address and port number.

786. Length of data structure containing destination

79IP Address/port info.

80*/

81if(sendto(sock, buf, dataLength+4, 0,

82

(struct sockaddr *)&name, sizeof(name)) < 0)

83

perror(“Sending datagram message”);

84npackets++;

85if (!(npackets % 1000))

86

printf(“%ld packets sent\n”, npackets);

87}

88close(sock);

89exit(0);

90

91

99

Page 105
Image 105
Proxima ASA 7911, 7910 manual name.sinfamily= AFINET