HighTechTalks DotNet Forums  

Socket exception

Dotnet Distributed Applications microsoft.public.dotnet.distributed_apps


Discuss Socket exception in the Dotnet Distributed Applications forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
bogma
 
Posts: n/a

Default Socket exception - 01-23-2007 , 04:59 AM






hi,
i have a real problem with the socket based communication of our
client-server application.
the application (c# .net 1.1) works well for all of our customers
except one.

i encounter socket exceptions in arbitrary intervals on this site (once
or twice a day).
the exception occurs on a socket.Send call and it states:

System.InvalidOperationException: Cannot block a call on this socket,
while an earlier async one is in progress.
at System.Net.Sockets.Socket.ValidateBlockingMode()
at System.Net.Sockets.Socket.Send(Byte[] buffer, Int32 offset, Int32
size, SocketFlags socketFlags)
at ComWin.TcpLib.CWTcpReceiver.SendRaw(Byte[] data, Int32 size)

I haven't got a clue how to track down this error. I have tried to
reproduce the failure but had no luck.

maybe somebody can give me a hint what can cause this error or what can
be done to locate the failure ...


Reply With Quote
  #2  
Old   
Bryan Phillips
 
Posts: n/a

Default Re: Socket exception - 01-25-2007 , 08:43 PM






Can you post the code inside your SendRaw method?

--
Bryan Phillips
MCSD, MCDBA, MCSE
Blog: http://bphillips76.spaces.live.com



"bogma" <m.bogensperger (AT) commend (DOT) com> wrote


Quote:
hi,
i have a real problem with the socket based communication of our
client-server application.
the application (c# .net 1.1) works well for all of our customers
except one.

i encounter socket exceptions in arbitrary intervals on this site (once
or twice a day).
the exception occurs on a socket.Send call and it states:

System.InvalidOperationException: Cannot block a call on this socket,
while an earlier async one is in progress.
at System.Net.Sockets.Socket.ValidateBlockingMode()
at System.Net.Sockets.Socket.Send(Byte[] buffer, Int32 offset, Int32
size, SocketFlags socketFlags)
at ComWin.TcpLib.CWTcpReceiver.SendRaw(Byte[] data, Int32 size)

I haven't got a clue how to track down this error. I have tried to
reproduce the failure but had no luck.

maybe somebody can give me a hint what can cause this error or what can
be done to locate the failure ...


Reply With Quote
  #3  
Old   
bogma
 
Posts: n/a

Default Re: Socket exception - 01-30-2007 , 05:40 AM



Hi Bryan,
the SendRaw code block is locked, so that only one thread can send.

public bool SendRaw(byte[] data, int size)
{
lock (m_sendlock)
{
if (m_socket != null)
{
if (data != null && size > 0)
{
try
{
int totalsent = 0;
do
{
int sent = m_socket.Send(data, totalsent, size - totalsent,
SocketFlags.None);
totalsent += sent;
} while (totalsent < size);
return true;
}
catch (Exception ex)
{
_log.Error("Error in CWTcpReceiver::Send:", ex);
}
}
}
}
return false;
}



Reply With Quote
  #4  
Old   
Bryan Phillips
 
Posts: n/a

Default Re: Socket exception - 03-03-2007 , 07:51 AM



What value are you setting to m_sendlock? It will need to be unique for
each thread.

--
Bryan Phillips
MCSD, MCDBA, MCSE
Blog: http://bphillips76.spaces.live.com



"bogma" <m.bogensperger (AT) commend (DOT) com> wrote


Quote:
Hi Bryan,
the SendRaw code block is locked, so that only one thread can send.

public bool SendRaw(byte[] data, int size)
{
lock (m_sendlock)
{
if (m_socket != null)
{
if (data != null && size > 0)
{
try
{
int totalsent = 0;
do
{
int sent = m_socket.Send(data, totalsent, size - totalsent,
SocketFlags.None);
totalsent += sent;
} while (totalsent < size);
return true;
}
catch (Exception ex)
{
_log.Error("Error in CWTcpReceiver::Send:", ex);
}
}
}
}
return false;
}


Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.