Hello Everybody
we are calling a Socket.SendTo( buffer, remote ) in a method in our Web
Service.
After doing this the Web Service won't stop any longer.
We get an System.CannotUnloadAppDomainException whenever we have called the
method mentioned above.
If we haven't called the method that opens a socket we can stop the
WebService without any problems.
See the code below and PLEASE help me :-)
public static ArrayList PingHost( Int32 lWaitTime )
{
//Initilize a Socket of the Type ICMP
socket = new Socket( AddressFamily.InterNetwork,
SocketType.Raw,
ProtocolType.Icmp );
......
nBytes = socket.SendTo( sendbuf,
PacketSize,
SocketFlags.None,
epServer );
if( nBytes == SOCKET_ERROR )
{
throw new Exception("Socket Error");
}
.......
while( System.Environment.TickCount < dwStart+lWaitTime )
{
if( socket.Poll( lWaitTime, SelectMode.SelectRead ) )
{
nBytes = socket.ReceiveFrom( ReceiveBuffer,
lLength,
SocketFlags.None,
ref
epServer );
}
}
.........
if( socket != null )
{
socket.Shutdown( SocketShutdown.Both );
socket.Close();
socket = null;
}
return RetVal;
}