Skip to content

Commit b999b56

Browse files
committed
Update main.go
1 parent accbb5d commit b999b56

File tree

1 file changed

+16
-1
lines changed
  • examples/rtl8720dn/webclient

1 file changed

+16
-1
lines changed

examples/rtl8720dn/webclient/main.go

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ var buf [4096]byte
4343
var lastRequestTime time.Time
4444
var conn net.Conn
4545

46+
var cnt int
47+
4648
func main() {
4749

4850
led := machine.LED
@@ -62,15 +64,28 @@ func main() {
6264

6365
func loop() {
6466
if conn != nil {
65-
for n, err := conn.Read(buf[:]); n > 0; n, err = conn.Read(buf[:]) {
67+
var err error
68+
var n int
69+
for n, err = conn.Read(buf[:]); n > 0; n, err = conn.Read(buf[:]) {
6670
if err != nil {
6771
println("Read error: " + err.Error())
6872
} else {
6973
print(string(buf[0:n]))
7074
}
7175
}
76+
if err != nil {
77+
println("Read error2: " + err.Error())
78+
}
79+
80+
err = conn.Close()
81+
if err != nil {
82+
println("Read error3: " + err.Error())
83+
}
84+
//rtl8720dn.NextSocketCh()
7285
}
7386
if time.Now().Sub(lastRequestTime).Milliseconds() >= 10000 {
87+
cnt++
88+
fmt.Printf("-- try %d --\r\n", cnt)
7489
makeHTTPRequest()
7590
}
7691
}

0 commit comments

Comments
 (0)