Socket exception in conjunction with HTTPRequest and Webclient

  • Thread starter Thread starter Roland
  • Start date Start date
R

Roland

Hello group,

I cannot make any HTTPRequest or WebClient using application run. I always
get an exception from somewhere inside System.Net.Sockets.Socket and cannot
figure out the reason.

In order to demonstrate the basic problem I just modified the
simplehelloworld example from .NET SDK 1.1 that way:

public class SimpleHelloWorld : Form {

[STAThread]
public static int Main(string[] args) {
if (args.Length < 2)
{
Console.WriteLine("Usage: downloadfile [localfile]");
return 0;
}

try
{
System.Net.WebClient client = new WebClient();
client.DownloadFile(args[0], args[1]);
}
catch(Exception e)
{
Console.WriteLine(e.ToString());
};
return 0;
}


As you can see the main function now attempts so download a file. I found
this sample somewhere in the web. It is just to demonstrate to you that I
don't do anything strange and forbidden. The error is almost the same:


Unbehandelte Ausnahme: System.TypeInitializationException: Der
Typeninitialisierer für System.Net.Sockets.Socket hat eine Ausnahme
verursacht. ---> System.Net.Sockets.SocketException: Ein Socketvorgang
konnte nicht ausgeführt werden, da dem
System Pufferspeicher fehlte oder eine Warteschlange voll war
at System.Net.Sockets.Socket.InitializeSockets()
at System.Net.Sockets.Socket..cctor()
--- Ende der internen Ausnahmestapelüberwachung ---
at System.Net.Connection.StartConnectionCallback(Object state, Boolean
wasSignalled)
System.Net.WebException: Das Zeitlimit für den Vorgang wurde überschritten.
at System.Net.HttpWebRequest.GetResponse()
at System.Net.WebClient.DownloadFile(String address, String FileName)
at
Microsoft.Samples.WinForms.Cs.SimpleHelloWorld.SimpleHelloWorld.Main(String[
] args) in
e:\Programme\Microsoft.NET\SDK\v1.1\QuickStart\winforms\samples\simplehellow
orld\cs\simplehelloworld.cs:line 35



I'm quite sure that there is nothing wrong with the Winsock on my sytem
(Win2k Prof SP4), because I have a lot of socket based apps programmed,
either in C++ or Delphi and never had such a problem.

One thing is probably worth to mention: I have a lot of network adapters of
different kind in my system. Could that cause the problem?

Any pointer welcome
Roland
 
Realy stange behavior! It that cases, an API sniffer is really usefull! Can
you post a download - location of the sniffer you've used? Is it free?

By the way: Does it work after dropping some (at least two) protocolls?

thanks, GP
 
Thank you for the link / memos!
Nevertheless I'm pretty sure, the bug first reported by Bill is really a
bug. It will make it hard to make .NET socket apps (and nearly every app
which relies on network functionality is a socket app) to run on systems
with a "moved history" :)

This is really an "evil" bug! Maybe the Socket class is the work of a
trainee, who thourght 50 protocols are enought ;-) I don't understand how a
programmer can build such constants into the source - code.

GP
 
This is really an "evil" bug! Maybe the Socket class is
the work of a trainee, who thourght 50 protocols are
enought ;-) I don't understand how a programmer can build
such constants into the source - code.

Günter,

my problem is solved. See the thread "Re: Bug in 1.1:
Socket.InitializeSockets"

Roland
 
Back
Top