C. menu structure, Sample tcp send program – Proxima ASA 7911 User Manual
Page 100
94
Sample TCP Send Program
1 /*******************************************************
2 * tcpsend.c
3 * Sends a message to a Serial Adapter using TCP
4 *
5 *******************************************************/
6
7 #include
8 #include
9 #include
10 #include
11 #include
12
13 #define DATA “Half a league, half a league...”
14 #define DATA1 0
15
16 main(argc, argv)
17 int argc;
18 char *argv[];
19 {
20 int sock;
21 short dataLength;
22 struct sockaddr_in server;
23 struct hostent *hp, *gethostbyname();
24 char buf[1024];
25
26 if (argc < 3) {
27
printf(“Usage: tcpsend hostname port#\n”);
28
exit(3);
29 }
30
31 /* Create socket. */
32 sock= socket(AF_INET, SOCK_STREAM, 0);
33 if (sock < 0) {
34
perror(“opening stream socket”);
35
exit(1);
36 }
37
38 /* Connect socket using name specified on command line */
39 server.sin_family= AF_INET;