完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
您好,我想使用GuiCTCP客户端通过TCPI设置RetryURL长度=100个字符向远程主机发送变量,实际上我不能减少这个大小,因为我需要把很多变量传递给PHP文件。RetryURL长度和最小化要发送的字符串中的参数数目。您能告诉我如何修改原始的GypCTCPoCube函数,让长字符串大约100个字符长吗?我不熟悉TCP协议,不知道如何修改自己的功能。谢谢您的帮助,
以上来自于百度翻译 以下为原文 Hello, I 'm trying to use GenericTCPClient to send out variables to distant host through TCP I set RemoteURL length =100 characters , actually i really can't reduce that size because i need to pass a lot of variables to a PHP file. So far, it won't work with a such long string but it does if i reduce RemoteURL length and minimize number of arguments in the string to be sent out. Can you tell me how to modify orginal GenericTCPClient function to let send large strings about 100 characters long? i'm not confortable with TCP protocol and do not know how i could modify this function by myself. Thank you for your help, BYTE ServerName[24] = "xxxxxxxxxxx.xxxxxxxxxxxx"; BYTE RemoteURL[100]; sprintf(RemoteURL,"/graphs/mk-infos.php?F=S_%s_nfo.txt&ID=%s&N=%s&T=%s&E=%s&S=%s&TO=%s&G=1",F_buffer,ID_buffer,N_buffer,T_buffer,S_buffer,S_buffer,TO_buffer); Attachment(s) GenericTCPClient.txt (4.29 KB) - downloaded 79 times |
|
相关推荐
9个回答
|
|
通常您检查“TcPISPATRAILY()”或类似的,并将此函数返回的数量作为要发送的字节数,并重复到完成。
以上来自于百度翻译 以下为原文 Usually you check for "TCPIsPutReady()" or alike , and send the amount returned by this function as the number of bytes to transmit; and repeat until finished. |
|
|
|
是的,我使用了MaxRuben的修改版本,但是长字符串不是通过TCPIs发送的,代码中有什么错误吗?[代码] 以上来自于百度翻译 以下为原文 Yes, I use a modified version from MaxRuben but long string are not sent through TCP Is there something wrong in that code ? void GenericTCPClient(void) { BYTE i; WORD w; BYTE vBuffer[9]; static DWORD Timer, t3; static TCP_SOCKET MySocket = INVALID_SOCKET; static enum _GenericTCPExampleState { SM_HOME = 0, SM_SOCKET_OBTAINED, SM_SEND_PART_2, SM_PROCESS_RESPONSE, SM_DISCONNECT, SM_DONE } GenericTCPExampleState = SM_DONE; switch(GenericTCPExampleState) { case SM_HOME: // Light LED : start transmission indication LED4_GREEN_IO = 1; MySocket = TCPOpen((DWORD)&ServerName[0], TCP_OPEN_RAM_HOST, ServerPort, TCP_PURPOSE_GENERIC_TCP_CLIENT); // Abort operation if no TCP socket of type TCP_PURPOSE_GENERIC_TCP_CLIENT is available // If this ever happens, you need to go add one to TCPIPConfig.h if(MySocket == INVALID_SOCKET) break; GenericTCPExampleState++; Timer = TickGet(); break; case SM_SOCKET_OBTAINED: // Wait for the remote server to accept our connection request if(!TCPIsConnected(MySocket)) { // Time out if too much time is spent in this state if(TickGet()-Timer > 5*TICK_SECOND) { // Close the socket so it can be used by other modules TCPDisconnect(MySocket); MySocket = INVALID_SOCKET; GenericTCPExampleState--; } break; } Timer = TickGet(); // Make certain the socket can be written to if(TCPIsPutReady(MySocket) < 125u) // Can possibly be smaller now... break; // Place the application protocol data into the transmit buffer. // For this example, we are connected to an HTTP server, so we'll send an HTTP GET request. TCPPutROMString(MySocket, (ROM BYTE*)"GET "); // Process RemoteURL that was previously made from Main.c . TCPPutString(MySocket, RemoteURL); TCPPutROMString(MySocket, (ROM BYTE*)" HTTP/1.0rnHost: "); GenericTCPExampleState++; TCPFlush(MySocket); break; case SM_SEND_PART_2: if(TCPIsPutReady(MySocket) < 125u) break; TCPPutString(MySocket, ServerName); TCPPutROMString(MySocket, (ROM BYTE*)"rnConnection: closernrn"); // Send the packet TCPFlush(MySocket); GenericTCPExampleState++; break; case SM_PROCESS_RESPONSE: // If application data is available, write it to the UART if(!TCPIsConnected(MySocket)) { GenericTCPExampleState = SM_DISCONNECT; // Do not break; We might still have data in the TCP RX FIFO waiting for us } // Get count of RX bytes waiting w = TCPIsGetReady(MySocket); // Obtian and print the server reply i = sizeof(vBuffer)-1; vBuffer = ' |