File tree Expand file tree Collapse file tree 1 file changed +27
-12
lines changed Expand file tree Collapse file tree 1 file changed +27
-12
lines changed Original file line number Diff line number Diff line change @@ -58,21 +58,27 @@ public void Connect()
58
58
cts . CancelAfter ( _connectionTimeout ) ;
59
59
void Cancel ( )
60
60
{
61
- if ( ! _socket . Connected )
61
+ if ( _socket != null && ! _socket . Connected )
62
62
{
63
63
_socket . Dispose ( ) ;
64
+ _socket = null ;
64
65
}
65
66
}
66
67
cts . Token . Register ( Cancel ) ;
67
68
68
69
_socket . Connect ( _endpoint ) ;
69
- if ( _socket . Connected )
70
- {
71
- success = true ;
72
- }
73
- else
70
+
71
+ if ( _socket != null )
74
72
{
75
- _socket . Dispose ( ) ;
73
+ if ( _socket . Connected )
74
+ {
75
+ success = true ;
76
+ }
77
+ else
78
+ {
79
+ _socket . Dispose ( ) ;
80
+ _socket = null ;
81
+ }
76
82
}
77
83
78
84
if ( success )
@@ -94,14 +100,23 @@ public async Task ConnectAsync()
94
100
{
95
101
await connTask ;
96
102
}
97
-
98
- if ( _socket . Connected )
103
+ else if ( _socket != null )
99
104
{
100
- success = true ;
105
+ _socket . Dispose ( ) ;
106
+ _socket = null ;
101
107
}
102
- else
108
+
109
+ if ( _socket != null )
103
110
{
104
- _socket . Dispose ( ) ;
111
+ if ( _socket . Connected )
112
+ {
113
+ success = true ;
114
+ }
115
+ else
116
+ {
117
+ _socket . Dispose ( ) ;
118
+ _socket = null ;
119
+ }
105
120
}
106
121
107
122
if ( success )
You can’t perform that action at this time.
0 commit comments