- void ConnectCallback (IAsyncResult ares)
- {
- try {
- curSocket.EndConnect (ares);
- } catch (SocketException se) {
- SocketError = se.SocketErrorCode;
- } catch (ObjectDisposedException) {
- SocketError = SocketError.OperationAborted;
- } finally {
- OnCompleted (this);
- }
- }
-
- internal void SendCallback (IAsyncResult ares)
- {
- try {
- BytesTransferred = curSocket.EndSend (ares);
- } catch (SocketException se){
- SocketError = se.SocketErrorCode;
- } catch (ObjectDisposedException) {
- SocketError = SocketError.OperationAborted;
- } finally {
- OnCompleted (this);
- }
- }
-
- internal void AcceptCallback (IAsyncResult ares)
- {
- try {
- AcceptSocket = curSocket.EndAccept (ares);
- } catch (SocketException ex) {
- SocketError = ex.SocketErrorCode;
- } catch (ObjectDisposedException) {
- SocketError = SocketError.OperationAborted;
- } finally {
- if (AcceptSocket == null)
- AcceptSocket = new Socket (curSocket.AddressFamily, curSocket.SocketType, curSocket.ProtocolType, (IntPtr)(-1));
- OnCompleted (this);
- }
- }
-
- internal void DisconnectCallback (IAsyncResult ares)
- {
- try {
- curSocket.EndDisconnect (ares);
- } catch (SocketException ex) {
- SocketError = ex.SocketErrorCode;
- } catch (ObjectDisposedException) {
- SocketError = SocketError.OperationAborted;
- } finally {
- OnCompleted (this);
- }
- }
-
- internal void ReceiveFromCallback (IAsyncResult ares)
- {
- try {
- BytesTransferred = curSocket.EndReceiveFrom (ares, ref remote_ep);
- } catch (SocketException ex) {
- SocketError = ex.SocketErrorCode;
- } catch (ObjectDisposedException) {
- SocketError = SocketError.OperationAborted;
- } finally {
- OnCompleted (this);
- }
- }
-
- internal void SendToCallback (IAsyncResult ares)
- {
- try {
- BytesTransferred = curSocket.EndSendTo (ares);
- } catch (SocketException ex) {
- SocketError = ex.SocketErrorCode;
- } catch (ObjectDisposedException) {
- SocketError = SocketError.OperationAborted;
- } finally {
- OnCompleted (this);
- }