473,395 Members | 2,446 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

System.Net.Sockets.Socket threw an exception

Hi,
My window application written in C# is throwing following exception
while connecting to one FTP location

The type initializer for System.Net.Sockets.Socket threw an exception

This exe is working fine on staging environment, (Window 2003) but
after migrating to production environment (Windows 2000), throwing this
exception at

_clientSocket = new
Socket(AddressFamily.InterNetwork,SocketType.Strea m, ProtocolType.Tcp);

- Only three Network cards are installed on production server
- while checking TCP/IP port status , there were few connections at
TIME_WAIT mode. but this might not be the cause for insufficient buffer
space.
- Recenetly we have installed Microsoft.Net\Framework\v1.1.4322

If somehow this is related to buffer space/long que, then how to clear
this and manage for future.

Not getting any idea from where to start. Any idea/suggestion would be
of great help.

Thanks

Apr 3 '06 #1
6 12967
Aero <at**********@gmail.com> wrote:
My window application written in C# is throwing following exception
while connecting to one FTP location

The type initializer for System.Net.Sockets.Socket threw an exception


Have you looked at the inner exception of that exception? It should
give more details about what went wrong.

It's very worrying if the type initializer threw an exception though -
that suggests that something is pretty wrong on the machine. (In
particular, it's unlikely to be anything to do with your code.)

Could you post a short but complete program which demonstrates the
problem?

See http://www.pobox.com/~skeet/csharp/complete.html for details of
what I mean by that.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Apr 3 '06 #2
Following is the code snippet which is causing the problem.
public void Login()
{
try
{
_clientSocket = new
Socket(AddressFamily.InterNetwork,SocketType.Strea m, ProtocolType.Tcp);
-----Error Point
}
catch(Exception Ex)
{
throw new IOException("Message: " + Ex.Message+ "Source:" + Ex.Source+
"Inner Exception" + Ex.InnerException);
}
IPEndPoint remoteEndPoint = new
IPEndPoint(Dns.Resolve(_remoteHost).AddressList[0], _remotePort);

try
{
_clientSocket.Connect(remoteEndPoint);
}
catch(Exception)
{
throw new IOException("Couldn't connect to remote server");
}

Apr 3 '06 #3
Aero <at**********@gmail.com> wrote:
Following is the code snippet which is causing the problem.


Rather than a snippet, could you post a short but *complete* program
which demonstrates the problem?

Also, what is the inner exception in this case, if any?

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Apr 3 '06 #4
Actually Code is too big but i am getting the error at
Socket(AddressFamily.InterNetwork,SocketType.Strea m, ProtocolType.Tcp);
Error Message: The type initializer for "Syetem.Net.Sockets.Socket"
threw an exception
Error Source: System.Net.Sockets.SocketException
Inner Exception An operation on a socket sould not be
performed because the system lacked sufficient buffer space or because
a queue was full
at System.Net.Sockets.Socket.InitializeSockets()
at System.Net.Sockets.Socket..cctor()

Please refer the following Microsoft article
FIX: Socket initialization does not succeed if your computer has more
than 50 network bound protocols
http://support.microsoft.com/?id=826757

Now we are planning to upgrade to Microsoft.Net Framework 2.0 on
production environment and lets see if it works or not.

Please suggest what can we do resolve this ASAP, even we are not sure
that will that work or not....just taking a chance.

Apr 4 '06 #5
Aero <at**********@gmail.com> wrote:
Actually Code is too big but i am getting the error at
Socket(AddressFamily.InterNetwork,SocketType.Strea m, ProtocolType.Tcp);
The existing code may be too big, but have you tried creating a sample
program just for the sake of pinning down the error?
Error Message: The type initializer for "Syetem.Net.Sockets.Socket"
threw an exception
Error Source: System.Net.Sockets.SocketException
Inner Exception An operation on a socket sould not be
performed because the system lacked sufficient buffer space or because
a queue was full
at System.Net.Sockets.Socket.InitializeSockets()
at System.Net.Sockets.Socket..cctor()

Please refer the following Microsoft article
FIX: Socket initialization does not succeed if your computer has more
than 50 network bound protocols
http://support.microsoft.com/?id=826757

Now we are planning to upgrade to Microsoft.Net Framework 2.0 on
production environment and lets see if it works or not.

Please suggest what can we do resolve this ASAP, even we are not sure
that will that work or not....just taking a chance.


Well, have you read the article it referenced?

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Apr 4 '06 #6
Hi,
I am not able to simulate this problem in any of our environments. This
is occuring only on production server.
I tried a sample code there and again it gave the same error.
While investigating we found that production server has .Net framework
1.1.4322 installed without service pack 1.
Now we are assuming that this might be the problem and today we are
going to upgrade this to .Net Framework 2.0.50215
Lets see what happens. If it works fine then its OK otherwise i'll have
think in different direction.
Thanks for your valuable inputs.

Apr 6 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: David Lozzi | last post by:
Hello, I'm receving the following on my webserver (Windows 2003 Server SP1) Event ID: 5 Source: Active Server Pages Error: File /KQShopping/ordercomplete4.asp Script Engine Exception. A...
0
by: Jack | last post by:
I am trying to develop a simple telnet client in MS.NET I have a small wrapper around the System.Net.Sockets.Socket class which takes care of sending and receiving data and handing it off to a...
1
by: Tony Caduto | last post by:
Hi, I was trying to create a new class derived from System.Net.Sockets.Socket and it seemed to be working until I tried to use the accept method. The accept method returns a Socket object and for...
4
by: Claire | last post by:
I need UDP server and client components. Udpclient control is a no-no, it doesnt do what I need and its buggy. I'm looking for some sample code for setting up the system.net.socket as a simple udp...
4
by: BadOmen | last post by:
Hi, What is the different between 'System.Net.Sockets.Socket' and 'System.Net.Sockets.TcpClient'? When do I use System.Net.Sockets.TcpClient and System.Net.Sockets.Socket?? Yours, Jonas
0
by: Sherry | last post by:
We are using the sample code "AsynchronousClient" from http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconnon-blockingclientsocketexample.asp. It works for the wired...
2
by: Stressed Out Developer | last post by:
We have an application that has a 200 count loop that does the following: ' Each time thru the loop we pass the next IP Address is a range (aka 192.168.4.50 thru 192.168.4.254) Try If...
2
by: Frank Uray | last post by:
Hi all I am using System.Net.Sockets.Socket to connect to my Mailserver (http://www.codeproject.com/csharp/despop3client.asp). It all works fine exept one thing: I do not know how I can find...
0
by: =?Utf-8?B?TWFydGluVGVlZnk=?= | last post by:
Hi, I've read a lot about the use of system sockets in Vb.net instead of winsock fine but how do i get a vb.net service running on a 2003 server to send a message to a desktop vb6 exe that can...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.