FINS/TCP Method |
| Section | ||
Sample Program |
|
|
| |
|
|
|
|
|
| 1 | #include <errno.h> |
|
|
| 2 | #include <stdio.h> |
|
|
| #include <sys/types.h> |
|
| |
| 3 |
|
| |
| 4 | #include <sys/socket.h> |
|
|
| 5 | #include <netinet/in.h> |
|
|
| 6 | #include <signal.h> |
|
|
| 7 |
|
|
|
| 8 | #define FINS_TCP_PORT 9600 |
| |
| 9 | #define SERV_IP_ADDR | "196.36.32.100"/* Ethernet Unit IP ADDRESS*/ |
|
| 10 | #define MAX_MSG 2010 |
|
|
| 11 | #define MAX_HEADER 32 |
|
|
| 12 | #define RESP_TIMEOUT 2 |
|
|
| 13 |
|
|
|
| 14 |
|
|
|
| 15 | /* |
|
|
| 16 | * FINS/TCP COMMUNICATIONS SAMPLE PROGRAM |
| |
| 17 | */ |
|
|
| 18 | main(argc,argv) |
|
|
| 19 | int argc; |
|
|
| 20 | char *argv[]; |
|
|
| 21 | { |
|
|
| 22 | int sockfd; |
|
|
| struct sockaddr_in ws_addr, cs_addr; |
| ||
| 23 |
| ||
| 24 | unsigned char fins_cmnd[MAX_MSG], fins_resp[MAX_MSG], fins_tcp_header[MAX_HEADER]; |
| |
| 25 | unsigned char srv_node_no, cli_node_no; |
| |
| 26 | int sendlen, recvlen; |
|
|
| 27 | char sid = 0; |
|
|
| 28 | extern recv_fail(); |
|
|
| 29 |
|
|
|
| 30 | /*GENERATE TCP | SOCKET*/ |
|
| 31 | if ((sockfd = socket(AF_INET,SOCK_STREAM,0)) < 0) |
| |
| 32 | err_exit("can't open stream socket"); |
|