Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7964843
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T05:59:53+00:00 2026-06-04T05:59:53+00:00

I have an asynchronous socket server. I have encountered a issue where problematic clients

  • 0

I have an asynchronous socket server. I have encountered a issue where problematic clients and hard to reproduce network events cause an insane number of byte[]’s to get pinned. Since all the threading to handle clients is implicit (I use BeginAcceptClient, and I use callbacks instead of threads that are explicitly instantiated) I don’t control the pinning process. By “implicit threading” I mean threads generated not by me directly, but by the runtime hosting my application.

At any rate the answer in this post shows how to unpin objects. Is it possible to override the behind the scenes pinning if I go on ahead and pin my byte[]’s myself, do the BeginRead and unpin during cleanup?

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T05:59:55+00:00Added an answer on June 4, 2026 at 5:59 am

    The answer in the post you linked to is completely wrong (I just left a comment there). Only when the last pinning handle (more general: pinning “reason” because there are other reasons than GCHandles) is removed the object is unpinned. You cannot force unpinning. That would be terribly unsafe. You could use safe managed code to do unsafe things which is even a security problem!

    Anyway, it does not make sense for you to try to prevent pinning of the object. Even if this was possible, which it is not, your process would crash at random times! Socket relies on pinning for correctness. It does not do this without reason.

    The solution is elsewhere:

    1. Create all buffers at application startup so all buffers are contiguous in memory. Use a buffer pool.
    2. Use a small number of large buffers and assign sections of it to individual clients.

    A small side note: Pinning is implemented differently from what you think. Pinning is not a flag you can turn on and off on an object. When you pin something, nothing special happens at first. Only when the GC runs, the GC notices that there are references with the special property that they are pinning. It then prevents the object from being moved.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a fairly generic C# socket server that uses the asynchronous methods of
I have a C# Asynchronous socket server, like so: private Socket _serverSocket; _serverSocket =
I have an Android app that communicates with a server via asynchronous socket connection
I have got a Client/Server Application that using Asynchronous Socket.My problem is i cant
I have an asynchronous UDP server class with a socket bound on IPAddress.Any, and
I have written a TCP server using the Socket class's asynchronous/IOCP methods, BeginSend()/BeginRead()/etc. I
I have created this asynchronous client socket that connects to a server and keeps
I currently work on a server/client program based on asynchronous socket. As far as
I'm developing an Asynchronous Game Server using .Net Socket Asynchronous Model( BeginAccept/EndAccept...etc.) The problem
I have a class that uses 'System.Net.Sockets.Socket' directly for network comunication, and currently I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.