user4717662
user4717662

Reputation:

.NET Core Socket.BeginAccept missing

I'm trying to do an asynchronous server using .NET Core and I'm following this guide: https://msdn.microsoft.com/fr-fr/library/fx6588te(v=vs.110).aspx

But the problem is that Visual Studio InteliSence doesn't find the BeginAccept method... I checked the corefx sources on github and the BeginAccept method exists.

Maybe the guide for .NET Framework is not valid for the .NET Core ...

Do you have any ideas for how I can build an asynchronous server using the Socket class ? Thanks

EDIT:

There is my project.json file:

{
  "version": "1.0.0-*",

  "dependencies": {
    "NETStandard.Library": "1.6.0"
  },

  "frameworks": {
    "netstandard1.6": {
      "imports": "dnxcore50"
    }
  }
}

Upvotes: 2

Views: 1400

Answers (1)

vcsjones
vcsjones

Reputation: 141598

This API is not available on .NET Core. You need to use AcceptAsync instead which works in .NET Core and .NET Framework. In general, the XyzBegin and XyzEnd style async methods are not available in .NET Core.

This function is a bit different from other *Async APIs in that it does not return a Task. Instead, you pass in a SocketAsyncEventArgs. One of the members of this is Completed which is an event that is raised when the Socket completes a connection.

Full documentation and examples on usage are in the linked documentation.

Upvotes: 2

Related Questions