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 8770593
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T17:35:08+00:00 2026-06-13T17:35:08+00:00

I got this error while compiling. what does it mean and how do i

  • 0

I got this error while compiling. what does it mean and how do i resolve it?

‘System.Net.Sockets.Socket.Dispose(bool)’ is inaccessible due to its protection level

Here are both of my files;

Listener.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using System.Net.Sockets;
namespace Multi_con_Server
{
class Listener
{
    Socket s;

    public bool Listening
    {
        get;
        private set;
    }
    public int Port
    {
        get;
        private set;
    }

    public Listener(int port)
    {
        Port = port;
        s = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
    }
    public void Start()
    {
        if (Listening)
            return;
        s.Bind(new IPEndPoint(0, Port));
        s.Listen(0);

        s.BeginAccept(callback, null);
        Listening = true;
    }
    public void Stop()
    {
        if (!Listening)
            return;

        s.Close();
        s.Dispose();
        s = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
    }

    void callback(IAsyncResult ar)
    {
        try
        {
            Socket s = this.s.EndAccept(ar);

            if (SocketAccepted != null)
            {
                SocketAccepted(s);
            }

            this.s.BeginAccept(callback, null);
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex.Message);
        }

    }
    public delegate void SocketAccecptedHandler(Socket e);
    public event SocketAccecptedHandler SocketAccepted;

}
}

Program.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using System.Net.Sockets;
namespace Multi_Con_C
{
class Program
{
    static void Main(string[] args)
    {
        Socket s = new Socket(AddressFamily.InterNetwork, SocketType.Stream,    
    ProtocolType.Tcp);
        s.Connect("127.0.0.1", 8);
        s.Close();
        s.Dispose();
    }
}
}
  • 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-13T17:35:09+00:00Added an answer on June 13, 2026 at 5:35 pm

    From MSDN, Socket.Close() automatically “releases all associated resources”. You can safely remove all occurances of Socket.Dispose() from your code.

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

Sidebar

Related Questions

while doing LINQ I got this Error. Cannot implicitly convert type 'System.DateTime?' to 'System.DateTime'.
I've got this error while compiling a big c# solution in Visual Studio 2010.
I tried to launch my project, but i got this error while compiling it
This is the error I got while compiling the jrxml file: Compiling to file...
i got this error while trying to rebind a grid: ( Parent page (
Got this error message while trying to load view: The model item passed into
Got this error message while trying to configure an entitydatasource in the designer: My
I got this error An error occurred while parsing EntityName. Line 1, position 61.
i have a problem while loading a UITableView on UITabBarController, i got this error
I am new to maven, while using mvn install I've got this error, any

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.