Proxima ASA 7910, 7911 manual Sample TCP Send Program

Models: 7911 7910

1 127
Download 127 pages 54.08 Kb
Page 100
Image 100
Sample TCP Send Program
94

Sample TCP Send Program

1/*******************************************************

2* tcpsend.c

3* Sends a message to a Serial Adapter using TCP

4*

5*******************************************************/

7#include <sys/types.h>

8#include <sys/socket.h> 9 #include <netinet/in.h>

10#include <netdb.h>

11#include <stdio.h>

13#define DATA “Half a league, half a league...”

14#define DATA1 0

16main(argc, argv)

17int argc;

18char *argv[];

19{

20int sock;

21short dataLength;

22struct sockaddr_in server;

23struct hostent *hp, *gethostbyname();

24char buf[1024];

26if (argc < 3) {

27printf(“Usage: tcpsend hostname port#\n”);

28exit(3);

29}

30

31/* Create socket. */

32sock= socket(AF_INET, SOCK_STREAM, 0);

33if (sock < 0) {

34perror(“opening stream socket”);

35exit(1);

36}

37

38/* Connect socket using name specified on command line */

39server.sin_family= AF_INET;

Page 100
Image 100
Proxima ASA 7910, 7911 manual Sample TCP Send Program