Re: Socket.Disconnect Method
- From: "Kevin Spencer" <uce@xxxxxxx>
- Date: Mon, 19 Jun 2006 16:06:41 -0400
In addition, the documentation mentions that this
method is new to Framework 2.0. It doesn't make a
whole lot of sense that they would introduce a new
method that only worked on platforms prior to Windows
2000.
The .Net platform is supported on Windows 2000, and Windows 98, and the
method is supported on Windows 2000 and Windows 98, but not on later
versions of Windows. So, it isn't as if the method is always useless, just
on systems later than Windows 2000.
I didn't mean to come across as if you were "taking it lightly," but the
bottom line is, it will not work on the platform you're developing on. So,
if I were you, I'd be exploring another avenue right now. The Sockets
classes are quite flexible and configurable, affording access to nearly
everything in the WinSock API. So, you should be able to work something out.
If you need any suggestions, let me know.
--
HTH,
Kevin Spencer
Microsoft MVP
Professional Chicken Salad Alchemist
I recycle.
I send everything back to the planet it came from.
"C. Coulter" <wizard2277@xxxxxxxxxxx> wrote in message
news:129dqe2j42e8ude@xxxxxxxxxxxxxxxxxxxxx
Kevin:
I appreciate your help. You are correct when you say that
error number 10022 is being raised when I call
"socket.disconnect(true)". The call to this method was
taken directly from the example given in the MSDN
example for this method. It immediately follows a
"socket.shutdown" call.
Although the exception list in the MSDN documentation
makes reference to the method not being supported on
platforms prior to Windows 2000, the Platforms list
at the bottom of the documentation explicitly mentions
Windows XP SP2 (which is the platform I'm testing with).
In addition, the documentation mentions that this
method is new to Framework 2.0. It doesn't make a
whole lot of sense that they would introduce a new
method that only worked on platforms prior to Windows
2000.
I had seen a couple of other posts that mentioned that
they had been unable to get this method to work. Hence,
my question still stands: could this be a known/unknown
bug in Framework 2.0/VS 2005? My code works if I comment
out the call to "socket.disconnect", so I have no reason
to think that it might be something else in the code.
I might also mention that this we are registered Microsoft
partners and that I have many years of programming
experience. I don't post to a newsgroup unless I have
exhausted all other avenues (meaning, I don't take it
lightly).
Do you or anyone else out there have any further input?
Thanks,
C. Coulter
wizard2277@xxxxxxxxxxx
Kevin Spencer wrote:
Be careful about using that word "bug" - the fact that one is unable to
use something doesn't necessarily imply that it is broken, and may end up
making you look foolish!
According to the documentation for this method, there are 3 distinct
possible exceptions that can be thrown when using this method:
PlatformNotSupportedException
This method requires Windows 2000 or earlier, or the exception will be
thrown.
ObjectDisposedException
The Socket object has been closed.
SocketException
An error occurred when attempting to access the socket. See the Remarks
section for more information.
Here is a more or less complete list of Socket Error Codes and their
meanings:
http://www.sockets.com/err_lst1.htm
It looks to me like the underlying error code could have been:
WSAEINVAL (10022) Invalid argument.
I'm not sure which of the 3 exceptions would have been raised if this
were the case, but the documentation does seem to indicate that this
parameter is not supported on Windows versions after Windows 2000.
Also, there are a few other notes in the documentation that may be
relevant:
If you are using a connection-oriented protocol, you can use this method
to close the socket. This method ends the connection and sets the
Connected property to false. However, if reuseSocket is true, you can
reuse the socket.
To ensure that all data is sent and received before the socket is closed,
you should call Shutdown before calling the Disconnect method.
If you need to call Disconnect without first calling Shutdown, you can
set the DontLingerSocket option to false and specify a nonzero time-out
interval to ensure that data queued for outgoing transmission is sent.
Disconnect then blocks until the data is sent or until the specified
time-out expires. If you set DontLinger to false and specify a zero
time-out interval, Close releases the connection and automatically
discards outgoing queued data.
Note
If you receive a SocketException, use the SocketException.ErrorCode
property to obtain the specific error code. After you have obtained this
code, refer to the Windows Sockets version 2 API error code documentation
in the MSDN library for a detailed description of the error.
Note
This member outputs trace information when you enable network tracing in
your application. For more information, see Network Tracing.
.
- References:
- Socket.Disconnect Method
- From: C. Coulter
- Re: Socket.Disconnect Method
- From: Kevin Spencer
- Re: Socket.Disconnect Method
- From: C. Coulter
- Socket.Disconnect Method
- Prev by Date: Re: Socket.Disconnect Method
- Next by Date: Re: VS2005 crashing when trying to Build a solution stored on a network drive
- Previous by thread: Re: Socket.Disconnect Method
- Next by thread: debug and release configurations
- Index(es):
Relevant Pages
|