FTP Correlation

xiaoxiao2021-04-11  909

The following sections describe how to associate a port issue of the FTP protocol: The process of transferring data includes establishing a data connection, selecting the appropriate port delivery parameters. The user and server have the default port. The client default data transfer port and protocol connection port is Consistent. The default port of the server's data transfer port and protocol is similar.

A FTP application port can specify a non-default port to transfer data. In this case, each time you use a different connection to accept data. Therefore, the association is required.

Processing method: Since the problem is that the host can specify a port to transfer data. The client and the server are used with the default port. The data is string with a 32-bit host address and a 16-bit TCP port address. This address is separate four 8-bit characters separated by a decimal point. The port of the port may be shown below.

Port H1, H2, H3, H4, P1, P2

P1 represents the front eight port characters

P2 represents the port character of the post-eighth bit

P1 & P2 can be paragrated in BUF10.

After getting the address and port of the host, press the high-low character to resolve the host port and put them in the variable, and parameterize this port in the corresponding location in Data.ws. Save this parameterized variable with lr_save_string.

Example: / ****************************************************************** *********************

* Created by Mercury Interactive Windows Sockets Recorder

* CREATED ON: SAT APR 15 21:55:23

*********************************************************** ****************** /

#include "lrs.h"

Actions ()

{

Char * newport;

Char * Userbuf;

Char BUF [255];

Char TMP [255];

INT IVAL, IHighVal, ILOWVAL

LR_think_time (12);

Lrs_send ("Socket2", "BUF8", LrsLASTARG

Lrs_Receive ("Socket2", "BUF9", LrsLASTARG

Lrs_create_socket ("Socket3", "TCP", "LocalHost = 0", "Backlog = 1", LrsLastarg);

/ * Get the port of the local host in Socket3 * /

Newport = lrs_get_socket_attrib ("Socket3", Local_Port);

LR_output_message ("Local Port% S", NewPort);

/ * PARSE newport to low and high order and save to 'portnum' parameter * /

IVAL = ATOI (NewPort);

ILOWVAL = (Word) & 0xFF;

Ihighval = (Word) ((DWORD) (IVAL) >> 8) & 0xFF);

STRCPY (BUF, ITOA (IHighVal, TMP, 10);

STRCAT (BUF, ",");

STRCAT (BUF, _ITOA (ILOWVAL, TMP, 10));

/ * Save the portnum to buf 10.

* Send BUF10

* "Port 199, 203, 74, 132, / r / n"

* The first 4 Numbers Are The IP and the fiffh argument must be * replaced with the new parameter. * / Lr_save_string (buf, "portnum");

/ * Get the content of buf10 and print to output for debug * /

Lrs_get_static_buffer ("Socket2", "BUF10", 0, -1, null;

Userbuf = lrs_get_user_buffer ("socket2");

LR_output_message ("BUF10 Content% S", Userbuf);

Lrs_send ("Socket2", "BUF10", Lrslastarg;

Lrs_receive ("Socket2", "BUF11", LrsLaseTarg;

Lrs_send ("Socket2", "BUF12", LrsLASTARG);

Lrs_Receive ("Socket2", "BUF13", Lrslastarg;

LRS_SET_ACCEPT_TIMEOUT (30, 0);

Lrs_accept_connection ("socket3", "socket4");

LRS_CLOSE_SOCKET ("Socket3");

Lrs_Receive ("Socket4", "BUF14", LrsLASTARG);

Lrs_close_socket ("Socket4");

Lrs_Receive ("Socket2", "BUF15", LrsLASTARG);

Return 0;

}

-------------------------------------------------- ------------------------------

转载请注明原文地址:https://www.9cbs.com/read-133537.html

New Post(0)