188
FINS/TCP Method Section 7-4
86 else
87 {
88 err_exit("FINS/TCP header send error");
89 }
90
91 /*RECEIVE FINS/TCP COMMAND (READ RECEIVE FUNCTIONS)*/
92 recvlen = 24;
93 if (tcp_recv(sockfd, fins_tcp_header, recvlen) == recvlen)
94 {
95 alarm(0); /*STOP RESPONSE MONITOR TIMER*/
96
97 /* CONFIRM WHETHER FINS NODE NUMBER SEND COMMAND
(CLIENT TO SERVER) WAS RECEIVED*/
98
if ((fins_tcp_header[8] != 0x00) |
|
(fins_tcp_header[9] != 0x00) |
|
99
(fins_tcp_header[10] !=
0x00) || (fins_tcp_header[11] !=
0x01))
100
{
101 err_exit("FINS/TCP illegal command error");
102 }
103
104 printf("FINS/TCP header receive length %d¥n",recvlen);
105 cli_node_no = fins_tcp_header[19];
106 srv_node_no = fins_tcp_header[23];
107 printf("FINS/TCP client Node No. = %d¥n",cli_node_no);
108 printf("FINS/TCP server Node No. = %d¥n",srv_node_no);
109 }
110 else
111 {
112 err_exit("TCP receive error");
113 }
114
115 /* SEND FINS/TCP COMMAND*/
116 /*
117 * GENERATE FINS COMMAND FRAME
118 */
119 fins_tcp_header[0] = 'F'; /* Header */
120 fins_tcp_header[1] = 'I';
121 fins_tcp_header[2] = 'N';
122 fins_tcp_header[3] = 'S';
123 fins_tcp_header[4] = 0x00; /* Length */
124 fins_tcp_header[5] = 0x00;
125 fins_tcp_header[6] = 0x00;
126 fins_tcp_header[7] = 8+18; /*Length of data from Command up to end of FINS frame */
127 fins_tcp_header[8] = 0x00; /* Command */
128 fins_tcp_header[9] = 0x00;
129 fins_tcp_header[10] = 0x00;
130 fins_tcp_header[11] = 0x02;
131 fins_tcp_header[12] = 0x00; /* Error Code */
132 fins_tcp_header[13] = 0x00;
133 fins_tcp_header[14] = 0x00;
134 fins_tcp_header[15] = 0x00;
135
136 /* SEND FINS/TCP COMMAND*/
137 sendlen = 16;
138 if (send(sockfd,fins_tcp_header,sendlen,0) == sendlen) {