Re: Socket.Disconnect Method
- From: "Kevin Spencer" <uce@xxxxxxx>
- Date: Mon, 19 Jun 2006 08:13:33 -0400
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.
--
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:129c5figgr4d0ec@xxxxxxxxxxxxxxxxxxxxx
Hi all!
I'm working on a socket application using synchronous
TCP sockets and the BackGroundWorker control. I would
like to reuse the socket without having to go through
the bother of setting socket options in code. This
is what the Socket.Disconnect(True) method is supposed
to accomplish. However, this method always fails with
an "invalid argument" exception. All the documentation
that I can find indicates that the argument is supposed
to be a Boolean.
Is this a bug in Framework 2.0 and/or VS .Net 2005? If
so, has there been any further word as to when Service
Pack 1 is supposed to come out? They announced SP1
would be out "in the first part of 2006" back in November.
Thanks for your help,
C. Coulter
wizard2277@xxxxxxxxxxxxxxxxx
.
- Follow-Ups:
- Re: Socket.Disconnect Method
- From: C. Coulter
- Re: Socket.Disconnect Method
- References:
- Socket.Disconnect Method
- From: C. Coulter
- Socket.Disconnect Method
- Prev by Date: debug and release configurations
- Next by Date: advise on treeview control and mdichild forms vb,net
- Previous by thread: Socket.Disconnect Method
- Next by thread: Re: Socket.Disconnect Method
- Index(es):
Relevant Pages
|
Loading