通过Telnet在base64中发送图像

时间:2014-02-13 23:10:45

标签: c++ base64 telnet

我目前正在为一所学校项目工作,并遇到了一个问题,即通过Telnet发送了大量数据。如果我发送的消息少于10KB,那就没问题了。但是,如果我发送的消息超过10KB,我会在运行几分钟后收到以下错误“501语法错误 - 行太长”。

有没有人知道更好的方法来实现我想要实现的目标,最好是使用send()?发送的数据是base64中图像的5页(以字为单位)。

谢谢,非常感谢任何帮助。

以下是我目前正在使用的代码部分,其中包含少量数据。

char *MailContents = new char[20000000];

std::ifstream in("C:\\test.txt");
std::string MailData((std::istreambuf_iterator<char(in)),std::istreambuf_iterator<char>()); 
//The following streams in the data into MailData() from a .txt file.


memcpy(MailContents, MailData.c_str(), MailData.length()); //This takes the data and copies it to MailContents
strcat(MailContents, "\r\n");

send(Connection, MailContents, strlen(MailContents), 0); //The following line will take the data in MailContents and echo it to the Telnet data section to be sent.

send(Connection, ".\r\n", strlen(".\r\n"), 0); //This line terminates the data entry and sends it.

0 个答案:

没有答案
相关问题