Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Buffer overflow #81

Open
Kamarov opened this issue Oct 1, 2020 · 2 comments
Open

Buffer overflow #81

Kamarov opened this issue Oct 1, 2020 · 2 comments

Comments

@Kamarov
Copy link

@Kamarov Kamarov commented Oct 1, 2020

Hello,

There is an issue when you trying send large packet using TCP Client in one shot.
The error is on server side.

Example:

`
TcpClient client = new TcpClient("127.0.0.1", 9001);
client.Connect();
var toSend = new byte[1024 * 1024 * 1024];// = 1Gb

        //On different  machines can it crash at 3 iteration, but sometimes it's passed without error on server
        for (int i = 0; i < 20; i++)
            client.Send(toSend);

`

Overflow Error is in Buffer.Reserve(long capacity).

But when you trying doing this that way:

`
TcpClient client = new TcpClient("127.0.0.1", 9001);
client.Connect();
var toSend = new byte[1024 * 1024 * 256];// = 256 Mb

        //...always passed on server
        for (int i = 0; i < 20 * 4; i++)
            client.Send(toSend);

`

@sojournercntl
Copy link

@sojournercntl sojournercntl commented Oct 13, 2020

When sending large amounts of data make sure to use proper message sizes. Split the send contents and merge it again on the client.

@Kamarov
Copy link
Author

@Kamarov Kamarov commented Oct 14, 2020

When sending large amounts of data make sure to use proper message sizes. Split the send contents and merge it again on the client.

Well, I'm doing it that way. But this problem does not exists in C++\CLI version of this library (see: https://github.com/chronoxor/CSharpServer) .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.