@@ -41,13 +41,13 @@ func NewClientConn(ctx context.Context, n uint8, sendFunc sendBytesFunc,
41
41
42
42
// clientHandshake initiates the client side GBN handshake.
43
43
// The handshake sequence from the client side is as follows:
44
- // 1. The client sends SYN to the server along with the N value that the
45
- // client wishes to use for the connection.
46
- // 2. The client then waits for the server to respond with SYN.
47
- // 3a. If the client receives SYN from the server then the client sends back
48
- // SYNACK.
44
+ // 1. The client sends SYN to the server along with the N value that the
45
+ // client wishes to use for the connection.
46
+ // 2. The client then waits for the server to respond with SYN.
47
+ // 3a. If the client receives SYN from the server, then the client sends back
48
+ // SYNACK.
49
49
// 3b. If the client does not receive SYN from the server within a given
50
- // timeout, then the client restarts the handshake from step 1.
50
+ // timeout, then the client restarts the handshake from step 1.
51
51
func (g * GoBackNConn ) clientHandshake () error {
52
52
// Spin off the recv function in a goroutine so that we can use
53
53
// a select to choose to timeout waiting for data from the receive
@@ -94,7 +94,10 @@ func (g *GoBackNConn) clientHandshake() error {
94
94
}
95
95
}()
96
96
97
- var resp Message
97
+ var (
98
+ resp Message
99
+ respSYN * PacketSYN
100
+ )
98
101
handshake:
99
102
for {
100
103
// start Handshake
@@ -142,8 +145,10 @@ handshake:
142
145
}
143
146
144
147
log .Debugf ("Client got %T" , resp )
145
- switch resp .(type ) {
148
+ switch r := resp .(type ) {
146
149
case * PacketSYN :
150
+ respSYN = r
151
+
147
152
break handshake
148
153
default :
149
154
}
@@ -155,7 +160,8 @@ handshake:
155
160
}
156
161
157
162
log .Debugf ("Client got SYN" )
158
- if resp .(* PacketSYN ).N != g .n {
163
+
164
+ if respSYN .N != g .n {
159
165
return io .EOF
160
166
}
161
167
0 commit comments