English 中文(简体)
阅读摘要
原标题:Reading from socket

I have data from socket, which is header and message. Header if of 5 bytes, 3rd and 4th is message length.

I am reading from socket, can someone suggest me good function, it will return me msg. assuming that i am reading 1024 bytes and it may happen that i have recived only partial data.

问题回答

为什么你们会读到1024字? 阅读5时,在实际got之前,在必要时重读。 5 tes(或错误)。 然后,你知道电文本身是多长时间的:在你拿到电文的所有数据之前,就反复读。 (关于每一次电话,你只要求获得与你实际想要的同样多的数据,当然,如果你重新阅读头盔,你先读2个字,然后按你要求发出3个字,即其余方。)

阅读你所知道的比你更清楚的是要求复杂,这意味着你必须记住,下读到的数据有些地方。

您应在读到足够数据后离开的休息室打电话read(<>/code>>recv()。 如果只收到部分数据,那么,在你收到足够包裹之前,你应再次读完。





相关问题
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?

热门标签