funny_falcon

Untitled

Dec 28th, 2020
1,052
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package main
  2.  
  3. import (
  4.         "net"
  5.         "sync"
  6.         "time"
  7.         "runtime/pprof"
  8.         "os"
  9. )
  10.  
  11. func main() {
  12.         ch := make(chan bool)
  13.         go func() {
  14.                 var mtx sync.Mutex
  15.                 ln, err := net.Listen("tcp", "127.0.0.1:8121")
  16.                 if err != nil { panic(err) }
  17.                 ch <- true
  18.                 _, err = ln.Accept()
  19.                 if err != nil { panic(err) }
  20.                 mtx.Lock()
  21.         }()
  22.  
  23.         <-ch
  24.  
  25.         var buf [16*1024]byte
  26.         conn, err := net.Dial("tcp", "127.0.0.1:8121")
  27.         if err != nil { panic(err) }
  28.         for i := 1; i < 100; i++ {
  29.                 go func() {
  30.                         for {
  31.                                 _, err = conn.Write(buf[:])
  32.                                 if err != nil { panic(err) }
  33.                         }
  34.                 }()
  35.         }
  36.  
  37.         time.Sleep(1*time.Second)
  38.         pprof.Lookup("goroutine").WriteTo(os.Stdout, 1)
  39. }
  40.  
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×