Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / .NET SDK / January 2005

Tip: Looking for answers? Try searching our database.

GetSockOpt exception

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Daryn Kiely - 11 Jan 2005 21:59 GMT
Hi, when I try to query for MaxConnections with GetSockOpt I am seeing an
exception and cannot figure out what is going on.  Here is a quick and dirty
test program and the output, hopefully you can
point me in the right direction:
---- Code -----

     {
        Socket s = new Socket (AddressFamily.InterNetwork,
SocketType.Stream, ProtocolType.IP);
        IPEndPoint ip = new IPEndPoint (IPAddress.Any, 9876);
        try
        {
           outputText.AppendText ("Attempt1:");
           outputText.AppendText (Environment.NewLine);
           s.GetSocketOption (SocketOptionLevel.Socket,
SocketOptionName.MaxConnections);
        }  
        catch (SocketException se1)
        {
           outputText.AppendText (se1.ToString ());
        }
        try
        {
           outputText.AppendText (Environment.NewLine);
           outputText.AppendText (Environment.NewLine);
           outputText.AppendText ("Attempt2:");
           outputText.AppendText (Environment.NewLine);
           s.GetSocketOption (SocketOptionLevel.IP,
SocketOptionName.MaxConnections);
        }  
        catch (SocketException se2)
        {
           outputText.AppendText (se2.ToString ());
        }
        try
        {
           outputText.AppendText (Environment.NewLine);
           outputText.AppendText (Environment.NewLine);
           outputText.AppendText ("Attempt3:");
           outputText.AppendText (Environment.NewLine);
           s.GetSocketOption (SocketOptionLevel.Tcp,
SocketOptionName.MaxConnections);
        }  
        catch (SocketException se3)
        {
           outputText.AppendText (se3.ToString ());
        }

----- Ouput -----
Attempt1:
System.Net.Sockets.SocketException: An unknown, invalid, or unsupported
option or level was specified in a getsockopt or setsockopt call
  at System.Net.Sockets.Socket.GetSocketOption(SocketOptionLevel
optionLevel, SocketOptionName optionName)
  at simplesocket.Form1.button1_Click(Object sender, EventArgs e) in
d:\teststuff\simplesocket\simplesocket\form1.cs:line 112

Attempt2:
System.Net.Sockets.SocketException: An unknown, invalid, or unsupported
option or level was specified in a getsockopt or setsockopt call
  at System.Net.Sockets.Socket.GetSocketOption(SocketOptionLevel
optionLevel, SocketOptionName optionName)
  at simplesocket.Form1.button1_Click(Object sender, EventArgs e) in
d:\teststuff\simplesocket\simplesocket\form1.cs:line 124

Attempt3:
System.Net.Sockets.SocketException: An invalid argument was supplied
  at System.Net.Sockets.Socket.GetSocketOption(SocketOptionLevel
optionLevel, SocketOptionName optionName)
  at simplesocket.Form1.button1_Click(Object sender, EventArgs e) in
d:\teststuff\simplesocket\simplesocket\form1.cs:line 136
Jared Parsons [MSFT] - 24 Jan 2005 19:38 GMT
I've never played with that SocketOption before but I think that you need to
bind the socket to the IPEndPoint before you can query that SocketOption

Signature

Jared Parson [MSFT]
jaredpar@online.microsoft.com

This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm

> Hi, when I try to query for MaxConnections with GetSockOpt I am seeing an
> exception and cannot figure out what is going on.  Here is a quick and
[quoted text clipped - 68 lines]
>   at simplesocket.Form1.button1_Click(Object sender, EventArgs e) in
> d:\teststuff\simplesocket\simplesocket\form1.cs:line 136

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.