Home > Software engineering >  On the TCP network data transmission
On the TCP network data transmission

Time:10-03

Within 500 ms needs to receive 7 m or so big data network packet, using VC implementation, need how to write a program at the receiving end? Not very grateful!

CodePudding user response:

7 0.5 MB/s=14 MB/s=112 mbit/s
MB network can't satisfy the,

CodePudding user response:

Here is gigabit network

CodePudding user response:

Simple, under the condition of network conditions, if you just for this one condition (500 ms receiving 7 MB bytes), then you just need to do the following:
 
Char * buf=NULL;
Int index=0, pkt_len=8 * 1024 * 1024;

//omit pointer check
Buf=new char [pkt_len];
Memset (buf, 0, pkt_len);

While (TRUE)
{
Int len=recv (buf + index, pkt_len - index);//a simplified API, just to illustrate the process
Index +=len;

If (index & gt;=x)//x for you or the packet length obtained by agreement head
{
//do anything
//you can do here protocol processing, can also be transferred to another buffer by the worker to do deal with
}
}


Scenario established by the above steps completely meet your requirements

CodePudding user response:

Don't need to be in a special setting.
You only need to use TCP, send, all while receiving.

Big data sent in a little at a time, such as a send 1 m.
Then, it is best not to have a disk IO operations, because this will be slow.

We have gigabit net, receives the speed up to 125 MB/s has been basically reached gigabit limit.

But some of the computer, because of the network card or the CPU, can not reach. So high, but 30 MB/s - 50 m/s general computer can achieve.

You just 14 MB/s, no problem at all.

CodePudding user response:

Actual use process, read the string data, the test can only read about 8000 of the length of the string, the need to adopt circulating reading way to read, in the long run this way there will be a certain a pack of couldn't read, don't know this kind of site you ever met a great god,

CodePudding user response:

Is now the application reads the amount of data that is to put a set to 8000 byte, read cycle, until all the 7 m data read, but after running more than a hour, can appear the phenomenon of network failed to get the data received, don't know how to solve,

CodePudding user response:

refer to 6th floor TDRCXT response:
is now the application reads the amount of data that is to put a set to 8000 byte, read cycle, until all the data of 7 m after reading, but more than an hour after the operation, can appear the phenomenon of network failed to get the data received, don't know how to solve,


Failure depends on reason, not all of the "failure" is said failure,
Such as asynchronous socket return 1, GetLasterror () to go back to 10056, this does not mean failure, but simply said, "I accept your request, your peace of mind would be better to wait for the results", so to say to want to specific analysis,

Another is "TCP stick pack" problem caused by reading data, the main reasons for this problem is the coder is not defined good "rules" or define the "rules", but there is no deal with "rules",

CodePudding user response:

Using VC programming, the recv function to receive data, the return value of 1, error code is 10060

CodePudding user response:

Because the connected party in 10060 after a period of time there is no right answer did not respond to a host or connection, connection attempts fail,

Any speed of sending and receiving ends inconsistent communication, need to use a large enough between them the FIFO buffer,
The use of any FIFO buffer, are all need to carefully consider the receiver to receive countless overtime according to and the sender sends the FIFO buffer is full in both cases what to do,
  • Related