Jez9999

Hi,

I'm having some trouble with an application of mine I'm making in C# with .NET.  It listens for a connection on a local port using Socket.BeginAccept, then when its callback is run it tries to connect out using Socket.BeginConnect.  On all but one of the machines I've tested it on (i've only tested it on about 5 though), it works.  On that one machine, I get a SocketException error when my code tries to connect out: "The attempted operation is not supported for the type of object referenced (10045)".

I think this might be an obscure problem to do with calling an asynchronous method (BeginConnect) from a thread that's running as the result of another asynchronous method (BeginAccept) - this thread seems to suggest that, although they were using HttpWebRequest instead of Socket - but I'm not sure.  It seems like it should work.  Perhaps it's the fact that McAfee firewall is installed on the machine that receives this error

If anyone knows why this doesn't work or has any ideas, please respond.  I'd like to figure out how to get this working on every test machine.  Here's the network trace for the machine where I get the error:

System.Net.Sockets Verbose: 0 : [2384] Socket#24861802::Socket(InterNetwork#2)
System.Net.Sockets Verbose: 0 : [2384] Exiting Socket#24861802::Socket()
System.Net.Sockets Verbose: 0 : [2384] Socket#24861802::Bind(1:15272#16792535)
System.Net.Sockets Verbose: 0 : [2384] Exiting Socket#24861802::Bind()
System.Net.Sockets Verbose: 0 : [2384] Socket#24861802::Listen(1#1)
System.Net.Sockets Verbose: 0 : [2384] Exiting Socket#24861802::Listen()
System.Net.Sockets Verbose: 0 : [2384] Socket#24861802::BeginAccept()
System.Net.Sockets Verbose: 0 : [2384] Exiting Socket#24861802::BeginAccept()  -> AcceptAsyncResult#22429634
System.Net.Sockets Verbose: 0 : [0784] Socket#6044116::Socket()
System.Net.Sockets Verbose: 0 : [0784] Exiting Socket#6044116::Socket()
System.Net.Sockets Verbose: 0 : [0784] Socket#24861802::EndAccept(AcceptAsyncResult#22429634)
System.Net.Sockets Verbose: 0 : [0784] Exiting Socket#24861802::EndAccept()  -> Socket#6044116
System.Net.Sockets Verbose: 0 : [0784] Socket#24861802::Close()
System.Net.Sockets Verbose: 0 : [0784] Socket#24861802::Dispose()
System.Net.Sockets Verbose: 0 : [0784] Exiting Socket#24861802::Close()
System.Net.Sockets Verbose: 0 : [0784] Socket#59817589::Socket(InterNetwork#2)
System.Net.Sockets Verbose: 0 : [0784] Exiting Socket#59817589::Socket()
System.Net.Sockets Verbose: 0 : [0784] Socket#59817589::BeginConnect(1:80#16777263)
System.Net.Sockets Verbose: 0 : [0784] Socket#59817589::BeginConnectEx()
System.Net.Sockets Verbose: 0 : [0784] Socket#59817589::InternalBind(0:0#0)
System.Net.Sockets Verbose: 0 : [0784] Exiting Socket#59817589::InternalBind()
System.Net.Sockets Verbose: 0 : [0784] Socket#6044116::Shutdown(Both#2)
System.Net.Sockets Verbose: 0 : [0784] Exiting Socket#6044116::Shutdown()
System.Net.Sockets Verbose: 0 : [0784] Socket#6044116::Close()
System.Net.Sockets Verbose: 0 : [0784] Socket#6044116::Dispose()
System.Net.Sockets Verbose: 0 : [0784] Exiting Socket#6044116::Close()
System.Net.Sockets Verbose: 0 : [0784] Socket#48209832::Socket(InterNetwork#2)
System.Net.Sockets Verbose: 0 : [0784] Exiting Socket#48209832::Socket()
System.Net.Sockets Verbose: 0 : [0784] Socket#48209832::Bind(1:15272#16792535)
System.Net.Sockets Verbose: 0 : [0784] Exiting Socket#48209832::Bind()
System.Net.Sockets Verbose: 0 : [0784] Socket#48209832::Listen(1#1)
System.Net.Sockets Verbose: 0 : [0784] Exiting Socket#48209832::Listen()
System.Net.Sockets Verbose: 0 : [0784] Socket#48209832::BeginAccept()
System.Net.Sockets Verbose: 0 : [0784] Socket#5773521::Socket(InterNetwork#2)
System.Net.Sockets Verbose: 0 : [0784] Exiting Socket#5773521::Socket()
System.Net.Sockets Verbose: 0 : [0784] Exiting Socket#48209832::BeginAccept()  -> AcceptOverlappedAsyncResult#54135081
System.Net.Sockets Verbose: 0 : [0784] Socket#63094882::Socket(InterNetwork#2)
System.Net.Sockets Verbose: 0 : [0784] Exiting Socket#63094882::Socket()
System.Net.Sockets Verbose: 0 : [0784] Socket#63094882::BeginConnect(1:80#16777263)
System.Net.Sockets Verbose: 0 : [0784] Socket#63094882::BeginConnectEx()
System.Net.Sockets Verbose: 0 : [0784] Socket#63094882::InternalBind(0:0#0)
System.Net.Sockets Verbose: 0 : [0784] Exiting Socket#63094882::InternalBind()
System.Net.Sockets Verbose: 0 : [0784] Socket#6044116::Close()
System.Net.Sockets Verbose: 0 : [0784] Socket#6044116::Dispose()
System.Net.Sockets Verbose: 0 : [0784] Exiting Socket#6044116::Dispose()
System.Net.Sockets Verbose: 0 : [0784] Exiting Socket#6044116::Close()
System.Net.Sockets Verbose: 0 : [2384] Socket#48209832::Close()
System.Net.Sockets Verbose: 0 : [2384] Socket#48209832::Dispose()
System.Net.Sockets Verbose: 0 : [2384] Exiting Socket#48209832::Close()
System.Net.Sockets Verbose: 0 : [2384] Socket#6044116::Close()
System.Net.Sockets Verbose: 0 : [2384] Socket#6044116::Dispose()
System.Net.Sockets Verbose: 0 : [2384] Exiting Socket#6044116::Dispose()
System.Net.Sockets Verbose: 0 : [2384] Exiting Socket#6044116::Close()




Re: .NET Framework Networking and Communication Problem with Sockets in .NET

.nathan.

Hello,

It seems like you might be heading the right direction. However, in the thread you referenced, there was a link to a KB article that discusses the possibility of Winsock corruption. The error your getting back is a Winsock error code 10045 which is talked about here.

Older versions of McAfee Firewall install LSPs (newer versions do not) and your error could possibly be related to this.

Are you running the latest version of McAfee Are there LSPs installed that could interfere with your test app (netsh winsock show catalog) Have you tried disabling McAfee to see if the error goes away




Re: .NET Framework Networking and Communication Problem with Sockets in .NET

Jez9999

.nathan. wrote:
Hello,

It seems like you might be heading the right direction. However, in the thread you referenced, there was a link to a KB article that discusses the possibility of Winsock corruption. The error your getting back is a Winsock error code 10045 which is talked about here.

I don't think this is Winsock corruption, though. As that thread said, it can often happen because of (badly written ) LSPs being installed on the machine, which seems the far more likely case here. The question is, which is at fault The LSP, the .net framework, or my app because I'm not supposed to be calling an async method from async code If it's the latter, I think they should put a big warning to developers on all such methods' pages, such as Socket.BeginReceive.

Older versions of McAfee Firewall install LSPs (newer versions do not) and your error could possibly be related to this.

Are you running the latest version of McAfee Are there LSPs installed that could interfere with your test app (netsh winsock show catalog) Have you tried disabling McAfee to see if the error goes away

It was a relatively recent version of McAfee. I'm pretty sure it does install some LSPs that could interfere with the app, though I'll have to connect to it again and check to be sure. I tried disabling McAfee's firewall, through the McAfee interface, to no avail; I suspect it just leaves whatever it inserted there, but it behaves differently (doesn't block any traffic).