English 中文(简体)
发送数据问题TCP/IP
原标题:Sending data issue TCP/IP
  • 时间:2012-05-23 17:45:19
  •  标签:
  • c++
  • tcp
//-push_back(in);}/char* *sendbuf=NULLL;* sendbuf=新字符[list.size()];/创建动态阵列以发送 std: list< chart; 列表; char; 在=NULL; 而(1) {scanf ("%c", & in; 如果( in) bread; 列表. push_ back(in);}/char. push_back(in);}/sendbuf=NULLL; char* sendbuf=新字符[lish[list.size()]; //creattrod strad: 复制数据(list.end) (list.end) () () list. (s-lives-liver-lift-liver-list-list-liff) list-list-list-list-list- sing it.
最佳回答

iResult_send= send( 连接 Socket, sendbuf, < strenglen > (int)strlen( sendbuf) , 0);

确定信件大小是错误的。 尝试对它使用列表. size () 。

问题回答

问题是: 您的数据不是无效终止的, 因此 strlen () 无法产生正确的大小 。 (大概是大值的一种方式) 。

正确为 :

    iResult_send = send( ConnectSocket, sendbuf, sizeof(char) * list.size(), 0 );

btw: 您可以忽略

        list.clear(); 
    }

变量在区块末被摧毁。





相关问题
Undefined reference

I m getting this linker error. I know a way around it, but it s bugging me because another part of the project s linking fine and it s designed almost identically. First, I have namespace LCD. Then I ...

C++ Equivalent of Tidy

Is there an equivalent to tidy for HTML code for C++? I have searched on the internet, but I find nothing but C++ wrappers for tidy, etc... I think the keyword tidy is what has me hung up. I am ...

Template Classes in C++ ... a required skill set?

I m new to C++ and am wondering how much time I should invest in learning how to implement template classes. Are they widely used in industry, or is this something I should move through quickly?

Print possible strings created from a Number

Given a 10 digit Telephone Number, we have to print all possible strings created from that. The mapping of the numbers is the one as exactly on a phone s keypad. i.e. for 1,0-> No Letter for 2->...

typedef ing STL wstring

Why is it when i do the following i get errors when relating to with wchar_t? namespace Foo { typedef std::wstring String; } Now i declare all my strings as Foo::String through out the program, ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

Window iconification status via Xlib

Is it possible to check with the means of pure X11/Xlib only whether the given window is iconified/minimized, and, if it is, how?

热门标签