Close closes the underlying pcap handle.
()
| 376 | |
| 377 | // Close closes the underlying pcap handle. |
| 378 | func (p *Handle) Close() { |
| 379 | p.closeMu.Lock() |
| 380 | defer p.closeMu.Unlock() |
| 381 | |
| 382 | if !p.isOpen() { |
| 383 | return |
| 384 | } |
| 385 | |
| 386 | atomic.StoreUint64(&p.stop, 1) |
| 387 | |
| 388 | // wait for packet reader to stop |
| 389 | p.mu.Lock() |
| 390 | defer p.mu.Unlock() |
| 391 | |
| 392 | p.pcapClose() |
| 393 | } |
| 394 | |
| 395 | // Error returns the current error associated with a pcap handle (pcap_geterr). |
| 396 | func (p *Handle) Error() error { |