Successfully reported this slideshow.
Your SlideShare is downloading. ×

Go for the would be network programmer

Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Loading in …3
×

Check these out next

1 of 159 Ad

More Related Content

Slideshows for you (20)

Similar to Go for the would be network programmer (20)

Advertisement

More from Eleanor McHugh (20)

Advertisement

Go for the would be network programmer

  1. 1. go for the would-be network programmer @feyeleanor go for the would-be network programmer 1 http://slides.games-with-brains.net/
  2. 2. twitter://@feyeleanor leanpub://GoNotebook go for the would-be network programmer http://slides.games-with-brains.net/
  3. 3. high voltage networking concurrency cryptography go for the would-be network programmer http://slides.games-with-brains.net/
  4. 4. http go for the would-be network programmer 4 http://slides.games-with-brains.net/
  5. 5. package main import ( . "fmt" "net/http" ) const MESSAGE = "hello world" const ADDRESS = ":1024" func main() { http.HandleFunc("/hello", Hello) if e := http.ListenAndServe(ADDRESS, nil); e != nil { Println(e) } } func Hello(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "text/plain") Fprintf(w, MESSAGE) } go for the would-be network programmer http://5 slides.games-with-brains.net/
  6. 6. package main import ( . "fmt" "net/http" ) const MESSAGE = "hello world" const ADDRESS = ":1024" func main() { http.HandleFunc("/hello", Hello) if e := http.ListenAndServe(ADDRESS, nil); e != nil { Println(e) } } func Hello(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "text/plain") Fprintf(w, MESSAGE) } go for the would-be network programmer http://6 slides.games-with-brains.net/
  7. 7. package main import ( . "fmt" "net/http" ) const MESSAGE = "hello world" const ADDRESS = ":1024" func main() { http.HandleFunc("/hello", Hello) if e := http.ListenAndServe(ADDRESS, nil); e != nil { Println(e) } } func Hello(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "text/plain") Fprintf(w, MESSAGE) } go for the would-be network programmer http://7 slides.games-with-brains.net/
  8. 8. package main import ( . "fmt" . "net/http" ) const MESSAGE = "hello world" const ADDRESS = ":1024" func main() { HandleFunc("/hello", Hello) if e := ListenAndServe(ADDRESS, nil); e != nil { Println(e) } } func Hello(w ResponseWriter, r *Request) { w.Header().Set("Content-Type", "text/plain") Fprintf(w, MESSAGE) } go for the would-be network programmer http://8 slides.games-with-brains.net/
  9. 9. package main import ( . "fmt" . ”net/http" ) const MESSAGE = "hello world" const ADDRESS = ":1024" func main() { HandleFunc("/hello", Hello) if e := ListenAndServe(ADDRESS, nil); e != nil { Println(e) } } func Hello(w ResponseWriter, r *Request) { w.Header().Set("Content-Type", "text/plain") Fprintf(w, MESSAGE) } go for the would-be network programmer http://9 slides.games-with-brains.net/
  10. 10. package main import ( . "fmt" . ”net/http" ) const MESSAGE = "hello world" const ADDRESS = ":1024" func main() { HandleFunc("/hello", Hello) if e := ListenAndServe(ADDRESS, nil); e != nil { Println(e) } } func Hello(w ResponseWriter, r *Request) { w.Header().Set("Content-Type", "text/plain") Fprintf(w, MESSAGE) } go for the would-be network programmer http://10 slides.games-with-brains.net/
  11. 11. package main import ( . "fmt" . ”net/http" ) const MESSAGE = "hello world" const ADDRESS = ":1024" func main() { HandleFunc("/hello", Hello) if e := ListenAndServe(ADDRESS, nil); e != nil { Println(e) } } func Hello(w ResponseWriter, r *Request) { w.Header().Set("Content-Type", "text/plain") Fprintf(w, MESSAGE) } go for the would-be network programmer http://11 slides.games-with-brains.net/
  12. 12. package main import ( . "fmt" . ”net/http" ) const MESSAGE = "hello world" const ADDRESS = ":1024" func main() { HandleFunc("/hello", Hello) if e := ListenAndServe(ADDRESS, nil); e != nil { Println(e) } } func Hello(w ResponseWriter, r *Request) { w.Header().Set("Content-Type", "text/plain") Fprintf(w, MESSAGE) } go for the would-be network programmer http://12 slides.games-with-brains.net/
  13. 13. package main import ( . "fmt" . ”net/http" ) const MESSAGE = "hello world" const ADDRESS = ":1024" func main() { HandleFunc("/hello", Hello) if e := ListenAndServe(ADDRESS, nil); e != nil { Println(e) } } func Hello(w ResponseWriter, r *Request) { w.Header().Set("Content-Type", "text/plain") Fprintf(w, MESSAGE) } go for the would-be network programmer http://13 slides.games-with-brains.net/
  14. 14. package main import ( . "fmt" . "net/http" ) const MESSAGE = "hello world" const ADDRESS = ":1024" func main() { HandleFunc("/hello", func(w ResponseWriter, r *Request) { w.Header().Set("Content-Type", "text/plain") Fprintf(w, MESSAGE) }) ListenAndServe(ADDRESS, nil) } go for the would-be network programmer http://14 slides.games-with-brains.net/
  15. 15. package main import ( . "fmt" . "net/http" ) const MESSAGE = "hello world" const ADDRESS = ":1024" func main() { HandleFunc("/hello", func(w ResponseWriter, r *Request) { w.Header().Set("Content-Type", "text/plain") Fprintf(w, MESSAGE) }) ListenAndServe(ADDRESS, nil) } go for the would-be network programmer http://15 slides.games-with-brains.net/
  16. 16. package main import ( . "fmt" . "net/http" ) const ADDRESS = ":1025" func main() { message := "hello world" HandleFunc("/hello", func(w ResponseWriter, r *Request) { w.Header().Set("Content-Type", "text/plain") Fprintf(w, message) }) ListenAndServeTLS(ADDRESS, "cert.pem", "key.pem", nil) } go for the would-be network programmer http://16 slides.games-with-brains.net/
  17. 17. package main import ( . "fmt" . "net/http" ) const ADDRESS = ":1025" func main() { message := "hello world" HandleFunc("/hello", func(w ResponseWriter, r *Request) { w.Header().Set("Content-Type", "text/plain") Fprintf(w, message) }) ListenAndServeTLS(ADDRESS, "cert.pem", "key.pem", nil) } go for the would-be network programmer http://17 slides.games-with-brains.net/
  18. 18. package main import ( . "fmt" . "net/http" ) const ADDRESS = ":1025" func main() { message := "hello world" HandleFunc("/hello", func(w ResponseWriter, r *Request) { w.Header().Set("Content-Type", "text/plain") Fprintf(w, message) }) ListenAndServeTLS(ADDRESS, "cert.pem", "key.pem", nil) } go for the would-be network programmer http://18 slides.games-with-brains.net/
  19. 19. package main import ( . "fmt" . "net/http" ) const ADDRESS = ":1025" func main() { message := "hello world" HandleFunc("/hello", func(w ResponseWriter, r *Request) { w.Header().Set("Content-Type", "text/plain") Fprintf(w, message) }) ListenAndServeTLS(ADDRESS, "cert.pem", "key.pem", nil) } go for the would-be network programmer http://19 slides.games-with-brains.net/
  20. 20. concurrency go for the would-be network programmer 20 http://slides.games-with-brains.net/
  21. 21. package main import . "fmt" import . "net/http" func main() { HandleFunc("/hello", func(w ResponseWriter, r *Request) { w.Header().Set("Content-Type", "text/plain") Fprintf(w, "hello world") }) done := make(chan bool) go func() { ListenAndServe(":1024", nil) done <- true }() ListenAndServeTLS(":1025", "cert.pem", "key.pem", nil) <- done } go for the would-be network programmer http://21 slides.games-with-brains.net/
  22. 22. package main import . "fmt" import . "net/http" func main() { HandleFunc("/hello", func(w ResponseWriter, r *Request) { w.Header().Set("Content-Type", "text/plain") Fprintf(w, "hello world") }) done := make(chan bool) go func() { ListenAndServe(":1024", nil) done <- true }() ListenAndServeTLS(":1025", "cert.pem", "key.pem", nil) <- done } go for the would-be network programmer http://22 slides.games-with-brains.net/
  23. 23. package main import . "fmt" import . "net/http" func main() { HandleFunc("/hello", func(w ResponseWriter, r *Request) { w.Header().Set("Content-Type", "text/plain") Fprintf(w, "hello world") }) done := make(chan bool) go func() { ListenAndServe(":1024", nil) done <- true }() ListenAndServeTLS(":1025", "cert.pem", "key.pem", nil) <- done } go for the would-be network programmer http://23 slides.games-with-brains.net/
  24. 24. package main import . "fmt" import . "net/http" func main() { HandleFunc("/hello", func(w ResponseWriter, r *Request) { w.Header().Set("Content-Type", "text/plain") Fprintf(w, "hello world") }) done := make(chan bool) go func() { ListenAndServe(":1024", nil) done <- true }() ListenAndServeTLS(":1025", "cert.pem", "key.pem", nil) <- done } go for the would-be network programmer http://24 slides.games-with-brains.net/
  25. 25. package main import . "fmt" import . "net/http" func main() { HandleFunc("/hello", func(w ResponseWriter, r *Request) { w.Header().Set("Content-Type", "text/plain") Fprintf(w, "hello world") }) done := make(chan bool) go func() { ListenAndServe(":1024", nil) done <- true }() ListenAndServeTLS(":1025", "cert.pem", "key.pem", nil) <- done } go for the would-be network programmer http://25 slides.games-with-brains.net/
  26. 26. package main import . "fmt" import . "net/http" func main() { HandleFunc("/hello", func(w ResponseWriter, r *Request) { w.Header().Set("Content-Type", "text/plain") Fprintf(w, "hello world") }) done := make(chan bool) go func() { ListenAndServe(":1024", nil) done <- true }() ListenAndServeTLS(":1025", "cert.pem", "key.pem", nil) <- done } go for the would-be network programmer http://26 slides.games-with-brains.net/
  27. 27. package main import . "fmt" import . "net/http" func main() { HandleFunc("/hello", func(w ResponseWriter, r *Request) { w.Header().Set("Content-Type", "text/plain") Fprintf(w, "hello world") }) done := make(chan bool) go func() { ListenAndServe(":1024", nil) done <- true }() ListenAndServeTLS(":1025", "cert.pem", "key.pem", nil) <- done } go for the would-be network programmer http://27 slides.games-with-brains.net/
  28. 28. package main import . "fmt" import . "net/http" func main() { HandleFunc("/hello", func(w ResponseWriter, r *Request) { w.Header().Set("Content-Type", "text/plain") Fprintf(w, "hello world") }) done := make(chan bool) go func() { ListenAndServe(":1024", nil) done <- true }() ListenAndServeTLS(":1025", "cert.pem", "key.pem", nil) <- done } go for the would-be network programmer http://28 slides.games-with-brains.net/
  29. 29. package main import . "fmt" import . "net/http" func main() { HandleFunc("/hello", func(w ResponseWriter, r *Request) { w.Header().Set("Content-Type", "text/plain") Fprintf(w, "hello world") }) done := make(chan bool) go func() { ListenAndServe(":1024", nil) done <- true }() ListenAndServeTLS(":1025", "cert.pem", "key.pem", nil) <- done } go for the would-be network programmer http://29 slides.games-with-brains.net/
  30. 30. package main import . "fmt" import . "net/http" func main() { HandleFunc("/hello", func(w ResponseWriter, r *Request) { w.Header().Set("Content-Type", "text/plain") Fprintf(w, "hello world") }) Spawn( func() { ListenAndServe(":1024", nil) }, func() { ListenAndServeTLS(":1025", "cert.pem", "key.pem", nil) }, ) } go for the would-be network programmer http://30 slides.games-with-brains.net/
  31. 31. package main import . "fmt" import . "net/http" func main() { HandleFunc("/hello", func(w ResponseWriter, r *Request) { w.Header().Set("Content-Type", "text/plain") Fprintf(w, "hello world") }) Spawn(func() { ListenAndServe(":1024", nil) }) Spawn(func() { ListenAndServeTLS(":1025", "cert.pem", "key.pem", nil) }) } go for the would-be network programmer http://31 slides.games-with-brains.net/
  32. 32. package main func Spawn(f ...func()) { done := make(chan bool) for _, s := range f { go func(server func()) { server() done <- true }(s) } for l := len(f); l > 0; l-- { <- done } } go for the would-be network programmer http://32 slides.games-with-brains.net/
  33. 33. package main func Spawn(f ...func()) { done := make(chan bool) for _, s := range f { go func(server func()) { server() done <- true }(s) } for l := len(f); l > 0; l-- { <- done } } go for the would-be network programmer http://33 slides.games-with-brains.net/
  34. 34. package main func Spawn(f ...func()) { done := make(chan bool) for _, s := range f { go func(server func()) { server() done <- true }(s) } for l := len(f); l > 0; l-- { <- done } } go for the would-be network programmer http://34 slides.games-with-brains.net/
  35. 35. package main func Spawn(f ...func()) { done := make(chan bool) for _, s := range f { go func(server func()) { server() done <- true }(s) } for l := len(f); l > 0; l-- { <- done } } go for the would-be network programmer http://35 slides.games-with-brains.net/
  36. 36. package main func Spawn(f ...func()) { done := make(chan bool) for _, s := range f { go func(server func()) { server() done <- true }(s) } for l := len(f); l > 0; l-- { <- done } } go for the would-be network programmer http://36 slides.games-with-brains.net/
  37. 37. package main func Spawn(f ...func()) { done := make(chan bool) for _, s := range f { go func(server func()) { server() done <- true }(s) } for l := len(f); l > 0; l-- { <- done } } go for the would-be network programmer http://37 slides.games-with-brains.net/
  38. 38. package main func Spawn(f ...func()) { done := make(chan bool) for _, s := range f { go func(server func()) { server() done <- true }(s) } for l := len(f); l > 0; l-- { <- done } } go for the would-be network programmer http://38 slides.games-with-brains.net/
  39. 39. waitgroups go for the would-be network programmer 39 http://slides.games-with-brains.net/
  40. 40. package main import . "fmt" import . "net/http" import "sync" func main() { HandleFunc("/hello", func(w ResponseWriter, r *Request) {}) var servers sync.WaitGroup servers.Add(1) go func() { defer servers.Done() ListenAndServe(":1024", nil) }() servers.Add(1) go func() { defer servers.Done() ListenAndServeTLS(":1025", "cert.pem", "key.pem", nil) }() servers.Wait() } go for the would-be network programmer http://40 slides.games-with-brains.net/
  41. 41. package main import . "fmt" import . "net/http" import "sync" func main() { HandleFunc("/hello", func(w ResponseWriter, r *Request) {}) var servers sync.WaitGroup servers.Add(1) go func() { defer servers.Done() ListenAndServe(":1024", nil) }() servers.Add(1) go func() { defer servers.Done() ListenAndServeTLS(":1025", "cert.pem", "key.pem", nil) }() servers.Wait() } go for the would-be network programmer http://41 slides.games-with-brains.net/
  42. 42. package main import . "fmt" import . "net/http" import "sync" func main() { HandleFunc("/hello", func(w ResponseWriter, r *Request) {}) var servers sync.WaitGroup servers.Add(1) go func() { defer servers.Done() ListenAndServe(":1024", nil) }() servers.Add(1) go func() { defer servers.Done() ListenAndServeTLS(":1025", "cert.pem", "key.pem", nil) }() servers.Wait() } go for the would-be network programmer http://42 slides.games-with-brains.net/
  43. 43. package main import . "fmt" import . "net/http" import "sync" func main() { HandleFunc("/hello", func(w ResponseWriter, r *Request) {}) var servers sync.WaitGroup servers.Add(1) go func() { defer servers.Done() ListenAndServe(":1024", nil) }() servers.Add(1) go func() { defer servers.Done() ListenAndServeTLS(":1025", "cert.pem", "key.pem", nil) }() servers.Wait() } go for the would-be network programmer http://43 slides.games-with-brains.net/
  44. 44. package main import . "fmt" import . "net/http" import "sync" func main() { HandleFunc("/hello", func(w ResponseWriter, r *Request) {}) var servers sync.WaitGroup servers.Add(1) go func() { defer servers.Done() ListenAndServe(":1024", nil) }() servers.Add(1) go func() { defer servers.Done() ListenAndServeTLS(":1025", "cert.pem", "key.pem", nil) }() servers.Wait() } go for the would-be network programmer http://44 slides.games-with-brains.net/
  45. 45. package main import . "fmt" import . "net/http" import "sync" var servers sync.WaitGroup func main() { HandleFunc("/hello", func(w ResponseWriter, r *Request) { w.Header().Set("Content-Type", "text/plain") Fprintf(w, "hello world") }) Spawn(func() { ListenAndServe(":1024", nil) }) Spawn(func() { ListenAndServeTLS(":1025", "cert.pem", "key.pem", nil) }) servers.Wait() } go for the would-be network programmer http://45 slides.games-with-brains.net/
  46. 46. package main import . "fmt" import . "net/http" import "sync" var servers sync.WaitGroup func main() { HandleFunc("/hello", func(w ResponseWriter, r *Request) { w.Header().Set("Content-Type", "text/plain") Fprintf(w, "hello world") }) Spawn(func() { ListenAndServe(":1024", nil) }) Spawn(func() { ListenAndServeTLS(":1025", "cert.pem", "key.pem", nil) }) servers.Wait() } go for the would-be network programmer http://46 slides.games-with-brains.net/
  47. 47. package main func Spawn(f ...func()) { for _, s := range f { servers.Add(1) go func(server func()) { defer servers.Done() server() }(s) } } go for the would-be network programmer http://47 slides.games-with-brains.net/
  48. 48. package main func Spawn(f ...func()) { for _, s := range f { servers.Add(1) go func(server func()) { defer servers.Done() server() }(s) } } go for the would-be network programmer http://48 slides.games-with-brains.net/
  49. 49. tcp go for the would-be network programmer 49 http://slides.games-with-brains.net/
  50. 50. package main import . "fmt" import "net" func main() { if listener, e := net.Listen("tcp", ":1024"); e == nil { for { if connection, e := listener.Accept(); e == nil { go func(c net.Conn) { defer c.Close() Fprintln(c, "hello world") }(connection) } } } } go for the would-be network programmer http://50 slides.games-with-brains.net/
  51. 51. package main import . "fmt" import "net" func main() { if listener, e := net.Listen("tcp", ":1024"); e == nil { for { if connection, e := listener.Accept(); e == nil { go func(c net.Conn) { defer c.Close() Fprintln(c, "hello world") }(connection) } } } } go for the would-be network programmer http://51 slides.games-with-brains.net/
  52. 52. package main import . "fmt" import "net" func main() { if listener, e := net.Listen("tcp", ":1024"); e == nil { for { if connection, e := listener.Accept(); e == nil { go func(c net.Conn) { defer c.Close() Fprintln(c, "hello world") }(connection) } } } } go for the would-be network programmer http://52 slides.games-with-brains.net/
  53. 53. package main import . "fmt" import "net" func main() { if listener, e := net.Listen("tcp", ":1024"); e == nil { for { if connection, e := listener.Accept(); e == nil { go func(c net.Conn) { defer c.Close() Fprintln(c, "hello world") }(connection) } } } } go for the would-be network programmer http://53 slides.games-with-brains.net/
  54. 54. package main import . "fmt" import "net" func main() { if listener, e := net.Listen("tcp", ":1024"); e == nil { for { if connection, e := listener.Accept(); e == nil { go func(c net.Conn) { defer c.Close() Fprintln(c, "hello world") }(connection) } } } } go for the would-be network programmer http://54 slides.games-with-brains.net/
  55. 55. package main import . "fmt" import "net" func main() { Listen("tcp", ":1024", func(c net.Conn) { defer c.Close() Fprintln(c, "hello world") }) } func Listen(p, a string, f func(net.Conn)) (e error) { var listener net.Listener if listener, e = net.Listen(p, a); e == nil { for { if connection, e := listener.Accept(); e == nil { go f(connection) } } } return } go for the would-be network programmer http://55 slides.games-with-brains.net/
  56. 56. package main import . "fmt" import "net" func main() { Listen("tcp", ":1024", func(c net.Conn) { defer c.Close() Fprintln(c, "hello world") }) } func Listen(p, a string, f func(net.Conn)) (e error) { var listener net.Listener if listener, e = net.Listen(p, a); e == nil { for { if connection, e := listener.Accept(); e == nil { go f(connection) } } } return } go for the would-be network programmer http://56 slides.games-with-brains.net/
  57. 57. package main import . "fmt" import "net" func main() { Listen("tcp", ":1024", func(c net.Conn) { defer c.Close() Fprintln(c, "hello world") }) } func Listen(p, a string, f func(net.Conn)) (e error) { var listener net.Listener if listener, e = net.Listen(p, a); e == nil { for { if connection, e := listener.Accept(); e == nil { go f(connection) } } } return } go for the would-be network programmer http://57 slides.games-with-brains.net/
  58. 58. package main import . "fmt" import "net" func main() { Listen("tcp", ":1024", func(c net.Conn) { defer c.Close() Fprintln(c, "hello world") }) } func Listen(p, a string, f func(net.Conn)) (e error) { var listener net.Listener if listener, e = net.Listen(p, a); e == nil { for { if connection, e := listener.Accept(); e == nil { go f(connection) } } } return } go for the would-be network programmer http://58 slides.games-with-brains.net/
  59. 59. package main import "bufio" import . "fmt" import "net" func main() { if c, e := net.Dial("tcp", ":1024"); e == nil { defer c.Close() if m, e := bufio.NewReader(c).ReadString('n'); e == nil { Printf(m) } } } go for the would-be network programmer http://59 slides.games-with-brains.net/
  60. 60. package main import "bufio" import . "fmt" import "net" func main() { if c, e := net.Dial("tcp", ":1024"); e == nil { defer c.Close() if m, e := bufio.NewReader(c).ReadString('n'); e == nil { Printf(m) } } } go for the would-be network programmer http://60 slides.games-with-brains.net/
  61. 61. package main import "bufio" import . "fmt" import "net" func main() { if c, e := net.Dial("tcp", ":1024"); e == nil { defer c.Close() if m, e := bufio.NewReader(c).ReadString('n'); e == nil { Printf(m) } } } go for the would-be network programmer http://61 slides.games-with-brains.net/
  62. 62. package main import "bufio" import . "fmt" import "net" func main() { if c, e := net.Dial("tcp", ":1024"); e == nil { defer c.Close() if m, e := bufio.NewReader(c).ReadString('n'); e == nil { Printf(m) } } } go for the would-be network programmer http://62 slides.games-with-brains.net/
  63. 63. package main import "bufio" import . "fmt" import "net" func main() { if c, e := net.Dial("tcp", ":1024"); e == nil { defer c.Close() if m, e := bufio.NewReader(c).ReadString('n'); e == nil { Printf(m) } } } go for the would-be network programmer http://63 slides.games-with-brains.net/
  64. 64. package main import "bufio" import . "fmt" import "net" func main() { if c, e := net.Dial("tcp", ":1024"); e == nil { defer c.Close() if m, e := bufio.NewReader(c).ReadString('n'); e == nil { Printf(m) } } } go for the would-be network programmer http://64 slides.games-with-brains.net/
  65. 65. package main import "bufio" import . "fmt" import "net" func main() { Dial("tcp", ":1024", func(c net.Conn) { if m, e := bufio.NewReader(c).ReadString('n'); e == nil { Printf(m) } }) } go for the would-be network programmer http://65 slides.games-with-brains.net/
  66. 66. package main import "bufio" import . "fmt" import "net" func main() { Dial("tcp", ":1024", func(c net.Conn) { if m, e := bufio.NewReader(c).ReadString('n'); e == nil { Printf(m) } }) } func Dial(p, a string, f func(net.Conn)) (e error) { var c net.Conn if c, e = net.Dial(p, a); e == nil { defer c.Close() f(c) } return } go for the would-be network programmer http://66 slides.games-with-brains.net/
  67. 67. package main import "bufio" import . "fmt" import "net" func main() { Dial("tcp", ":1024", func(c net.Conn) { if m, e := bufio.NewReader(c).ReadString('n'); e == nil { Printf(m) } }) } func Dial(p, a string, f func(net.Conn)) (e error) { var c net.Conn if c, e = net.Dial(p, a); e == nil { defer c.Close() f(c) } return } go for the would-be network programmer http://67 slides.games-with-brains.net/
  68. 68. package main import "bufio" import . "fmt" import "net" func main() { Dial("tcp", ":1024", func(c net.Conn) { if m, e := bufio.NewReader(c).ReadString('n'); e == nil { Printf(m) } }) } func Dial(p, a string, f func(net.Conn)) (e error) { var c net.Conn if c, e = net.Dial(p, a); e == nil { defer c.Close() f(c) } return } go for the would-be network programmer http://68 slides.games-with-brains.net/
  69. 69. package main import "bufio" import . "fmt" import "net" func main() { Dial("tcp", ":1024", func(c net.Conn) { if m, e := bufio.NewReader(c).ReadString('n'); e == nil { Printf(m) } }) } func Dial(p, a string, f func(net.Conn)) (e error) { var c net.Conn if c, e = net.Dial(p, a); e == nil { defer c.Close() f(c) } return } go for the would-be network programmer http://69 slides.games-with-brains.net/
  70. 70. tcp/tls go for the would-be network programmer 70 http://slides.games-with-brains.net/
  71. 71. package main import "crypto/tls" import . "fmt" func main() { Listen(":1025", ConfigTLS("scert", "skey"), func(c *tls.Conn) { Fprintln(c, "hello world") }) } go for the would-be network programmer http://71 slides.games-with-brains.net/
  72. 72. package main import "crypto/tls" import . "fmt" func main() { Listen(":1025", ConfigTLS("scert", "skey"), func(c *tls.Conn) { Fprintln(c, "hello world") }) } go for the would-be network programmer http://72 slides.games-with-brains.net/
  73. 73. package main import "crypto/tls" import . "fmt" func main() { Listen(":1025", ConfigTLS("scert", "skey"), func(c *tls.Conn) { Fprintln(c, "hello world") }) } go for the would-be network programmer http://73 slides.games-with-brains.net/
  74. 74. package main import "crypto/rand" import "crypto/tls" func ConfigTLS(c, k string) (r *tls.Config) { if cert, e := tls.LoadX509KeyPair(c, k); e == nil { r = &tls.Config{ Certificates: []tls.Certificate{ cert }, Rand: rand.Reader, } } return } go for the would-be network programmer http://74 slides.games-with-brains.net/
  75. 75. package main import "crypto/rand" import "crypto/tls" func ConfigTLS(c, k string) (r *tls.Config) { if cert, e := tls.LoadX509KeyPair(c, k); e == nil { r = &tls.Config{ Certificates: []tls.Certificate{ cert }, Rand: rand.Reader, } } return } go for the would-be network programmer http://75 slides.games-with-brains.net/
  76. 76. package main import "crypto/rand" import "crypto/tls" func ConfigTLS(c, k string) (r *tls.Config) { if cert, e := tls.LoadX509KeyPair(c, k); e == nil { r = &tls.Config{ Certificates: []tls.Certificate{ cert }, Rand: rand.Reader, } } return } go for the would-be network programmer http://76 slides.games-with-brains.net/
  77. 77. package main import "crypto/rand" import "crypto/tls" func ConfigTLS(c, k string) (r *tls.Config) { if cert, e := tls.LoadX509KeyPair(c, k); e == nil { r = &tls.Config{ Certificates: []tls.Certificate{ cert }, Rand: rand.Reader, } } return } go for the would-be network programmer http://77 slides.games-with-brains.net/
  78. 78. package main import "crypto/rand" import "crypto/tls" func ConfigTLS(c, k string) (r *tls.Config) { if cert, e := tls.LoadX509KeyPair(c, k); e == nil { r = &tls.Config{ Certificates: []tls.Certificate{ cert }, Rand: rand.Reader, } } return } go for the would-be network programmer http://78 slides.games-with-brains.net/
  79. 79. package main import "crypto/tls" func Listen(a string, conf *tls.Config, f func(*tls.Conn)) { if listener, e := tls.Listen("tcp", a, conf); e == nil { for { if connection, e := listener.Accept(); e == nil { go func(c *tls.Conn) { defer c.Close() f(c) }(connection.(*tls.Conn)) } } } } go for the would-be network programmer http://79 slides.games-with-brains.net/
  80. 80. package main import "crypto/tls" func Listen(a string, conf *tls.Config, f func(*tls.Conn)) { if listener, e := tls.Listen("tcp", a, conf); e == nil { for { if connection, e := listener.Accept(); e == nil { go func(c *tls.Conn) { defer c.Close() f(c) }(connection.(*tls.Conn)) } } } } go for the would-be network programmer http://80 slides.games-with-brains.net/
  81. 81. package main import "crypto/tls" func Listen(a string, conf *tls.Config, f func(*tls.Conn)) { if listener, e := tls.Listen("tcp", a, conf); e == nil { for { if connection, e := listener.Accept(); e == nil { go func(c *tls.Conn) { defer c.Close() f(c) }(connection.(*tls.Conn)) } } } } go for the would-be network programmer http://81 slides.games-with-brains.net/
  82. 82. package main import "crypto/tls" func Listen(a string, conf *tls.Config, f func(*tls.Conn)) { if listener, e := tls.Listen("tcp", a, conf); e == nil { for { if connection, e := listener.Accept(); e == nil { go func(c *tls.Conn) { defer c.Close() f(c) }(connection.(*tls.Conn)) } } } } go for the would-be network programmer http://82 slides.games-with-brains.net/
  83. 83. package main import “crypto/tls" import "net" func Listen(a string, conf *tls.Config, f func(net.Conn)) { if listener, e := tls.Listen("tcp", a, conf); e == nil { for { if connection, e := listener.Accept(); e == nil { go func(c net.Conn) { defer c.Close() f(c) }(connection) } } } } go for the would-be network programmer http://83 slides.games-with-brains.net/
  84. 84. package main import "crypto/tls" import "net" func Listen(a string, conf *tls.Config, f func(net.Conn)) { if listener, e := tls.Listen("tcp", a, conf); e == nil { for { if connection, e := listener.Accept(); e == nil { go func(c net.Conn) { defer c.Close() f(c) }(connection) } } } } go for the would-be network programmer http://84 slides.games-with-brains.net/
  85. 85. package main import "bufio" import . "fmt" import "net" func main() { Dial(":1025", ConfigTLS("ccert", "ckey"), func(c net.Conn) { if m, e := bufio.NewReader(c).ReadString('n'); e == nil { Printf(m) } }) } go for the would-be network programmer http://85 slides.games-with-brains.net/
  86. 86. package main import "bufio" import . "fmt" import "net" func main() { Dial(":1025", ConfigTLS("ccert", "ckey"), func(c net.Conn) { if m, e := bufio.NewReader(c).ReadString('n'); e == nil { Printf(m) } }) } go for the would-be network programmer http://86 slides.games-with-brains.net/
  87. 87. package main import "bufio" import . "fmt" import "net" func main() { Dial(":1025", ConfigTLS("ccert", "ckey"), func(c net.Conn) { if m, e := bufio.NewReader(c).ReadString('n'); e == nil { Printf(m) } }) } go for the would-be network programmer http://87 slides.games-with-brains.net/
  88. 88. package main import "crypto/tls" func ConfigTLS(c, k string) (r *tls.Config) { if cert, e := tls.LoadX509KeyPair(c, k); e == nil { r = &tls.Config{ Certificates: []tls.Certificate{ cert }, InsecureSkipVerify: true, } } return } go for the would-be network programmer http://88 slides.games-with-brains.net/
  89. 89. package main import "crypto/tls" func ConfigTLS(c, k string) (r *tls.Config) { if cert, e := tls.LoadX509KeyPair(c, k); e == nil { r = &tls.Config{ Certificates: []tls.Certificate{ cert }, InsecureSkipVerify: true, } } return } go for the would-be network programmer http://89 slides.games-with-brains.net/
  90. 90. package main import "crypto/tls" func ConfigTLS(c, k string) (r *tls.Config) { if cert, e := tls.LoadX509KeyPair(c, k); e == nil { r = &tls.Config{ Certificates: []tls.Certificate{ cert }, InsecureSkipVerify: true, } } return } go for the would-be network programmer http://90 slides.games-with-brains.net/
  91. 91. package main import “crypto/tls" import "net" func Dial(a string, conf *tls.Config, f func(net.Conn)) { if c, e := tls.Dial("tcp", a, conf); e == nil { defer c.Close() f(c) } } go for the would-be network programmer http://91 slides.games-with-brains.net/
  92. 92. package main import “crypto/tls" import "net" func Dial(a string, conf *tls.Config, f func(net.Conn)) { if c, e := tls.Dial("tcp", a, conf); e == nil { defer c.Close() f(c) } } go for the would-be network programmer http://92 slides.games-with-brains.net/
  93. 93. udp go for the would-be network programmer 93 http://slides.games-with-brains.net/
  94. 94. package main import "net" func main() { HELLO_WORLD := []byte("Hello Worldn") Listen(":1024", func(c *net.UDPConn, a *net.UDPAddr, b []byte) { c.WriteToUDP(HELLO_WORLD, a) }) } func Listen(a string, f func(*net.UDPConn, *net.UDPAddr, []byte)) { if address, e := net.ResolveUDPAddr("udp", a); e == nil { if conn, e := net.ListenUDP("udp", address); e == nil { for b := make([]byte, 1024); ; b = make([]byte, 1024) { if n, client, e := conn.ReadFromUDP(b); e == nil { go f(conn, client, b[:n]) } } } } return } go for the would-be network programmer http://94 slides.games-with-brains.net/
  95. 95. package main import "net" func main() { HELLO_WORLD := []byte("Hello Worldn”) Listen(":1024", func(c *net.UDPConn, a *net.UDPAddr, b []byte) { c.WriteToUDP(HELLO_WORLD, a) }) } func Listen(a string, f func(*net.UDPConn, *net.UDPAddr, []byte)) { if address, e := net.ResolveUDPAddr("udp", a); e == nil { if conn, e := net.ListenUDP("udp", address); e == nil { for b := make([]byte, 1024); ; b = make([]byte, 1024) { if n, client, e := conn.ReadFromUDP(b); e == nil { go f(conn, client, b[:n]) } } } } return } go for the would-be network programmer http://95 slides.games-with-brains.net/
  96. 96. package main import "net" func main() { HELLO_WORLD := []byte("Hello Worldn") Listen(":1024", func(c *net.UDPConn, a *net.UDPAddr, b []byte) { c.WriteToUDP(HELLO_WORLD, a) }) } func Listen(a string, f func(*net.UDPConn, *net.UDPAddr, []byte)) { if address, e := net.ResolveUDPAddr("udp", a); e == nil { if conn, e := net.ListenUDP("udp", address); e == nil { for b := make([]byte, 1024); ; b = make([]byte, 1024) { if n, client, e := conn.ReadFromUDP(b); e == nil { go f(conn, client, b[:n]) } } } } return } go for the would-be network programmer http://96 slides.games-with-brains.net/
  97. 97. package main import "net" func main() { HELLO_WORLD := []byte("Hello Worldn") Listen(":1024", func(c *net.UDPConn, a *net.UDPAddr, b []byte) { c.WriteToUDP(HELLO_WORLD, a) }) } func Listen(a string, f func(*net.UDPConn, *net.UDPAddr, []byte)) { if address, e := net.ResolveUDPAddr("udp", a); e == nil { if conn, e := net.ListenUDP("udp", address); e == nil { for b := make([]byte, 1024); ; b = make([]byte, 1024) { if n, client, e := conn.ReadFromUDP(b); e == nil { go f(conn, client, b[:n]) } } } } return } go for the would-be network programmer http://97 slides.games-with-brains.net/
  98. 98. package main import "net" func main() { HELLO_WORLD := []byte("Hello Worldn") Listen(":1024", func(c *net.UDPConn, a *net.UDPAddr, b []byte) { c.WriteToUDP(HELLO_WORLD, a) }) } func Listen(a string, f func(*net.UDPConn, *net.UDPAddr, []byte)) { if address, e := net.ResolveUDPAddr("udp", a); e == nil { if conn, e := net.ListenUDP("udp", address); e == nil { for b := make([]byte, 1024); ; b = make([]byte, 1024) { if n, client, e := conn.ReadFromUDP(b); e == nil { go f(conn, client, b[:n]) } } } } return } go for the would-be network programmer http://98 slides.games-with-brains.net/
  99. 99. package main import "net" func main() { HELLO_WORLD := []byte("Hello Worldn") Listen(":1024", func(c *net.UDPConn, a *net.UDPAddr, b []byte) { c.WriteToUDP(HELLO_WORLD, a) }) } func Listen(a string, f func(*net.UDPConn, *net.UDPAddr, []byte)) { if address, e := net.ResolveUDPAddr("udp", a); e == nil { if conn, e := net.ListenUDP("udp", address); e == nil { for b := make([]byte, 1024); ; b = make([]byte, 1024) { if n, client, e := conn.ReadFromUDP(b); e == nil { go f(conn, client, b[:n]) } } } } return } go for the would-be network programmer http://99 slides.games-with-brains.net/
  100. 100. package main import "net" func main() { HELLO_WORLD := []byte("Hello Worldn") Listen(":1024", func(c *net.UDPConn, a *net.UDPAddr, b []byte) { c.WriteToUDP(HELLO_WORLD, a) }) } func Listen(a string, f func(*net.UDPConn, *net.UDPAddr, []byte)) { if address, e := net.ResolveUDPAddr("udp", a); e == nil { if conn, e := net.ListenUDP("udp", address); e == nil { for b := make([]byte, 1024); ; b = make([]byte, 1024) { if n, client, e := conn.ReadFromUDP(b); e == nil { go f(conn, client, b[:n]) } } } } return } go for the would-be network programmer http://100 slides.games-with-brains.net/
  101. 101. package main import "net" func main() { HELLO_WORLD := []byte("Hello Worldn") Listen(":1024", func(c *net.UDPConn, a *net.UDPAddr, b []byte) { c.WriteToUDP(HELLO_WORLD, a) }) } func Listen(a string, f func(*net.UDPConn, *net.UDPAddr, []byte)) { if address, e := net.ResolveUDPAddr("udp", a); e == nil { if conn, e := net.ListenUDP("udp", address); e == nil { for b := make([]byte, 1024); ; b = make([]byte, 1024) { if n, client, e := conn.ReadFromUDP(b); e == nil { go f(conn, client, b[:n]) } } } } return } go for the would-be network programmer http://101 slides.games-with-brains.net/
  102. 102. package main import "net" func main() { HELLO_WORLD := []byte("Hello Worldn") Listen(":1024", func(c *net.UDPConn, a *net.UDPAddr, b []byte) { c.WriteToUDP(HELLO_WORLD, a) }) } func Listen(a string, f func(*net.UDPConn, *net.UDPAddr, []byte)) { if address, e := net.ResolveUDPAddr("udp", a); e == nil { if conn, e := net.ListenUDP("udp", address); e == nil { for b := make([]byte, 1024); ; b = make([]byte, 1024) { if n, client, e := conn.ReadFromUDP(b); e == nil { go f(conn, client, b[:n]) } } } } return } go for the would-be network programmer http://102 slides.games-with-brains.net/
  103. 103. package main import "net" func main() { HELLO_WORLD := []byte("Hello Worldn") Listen(":1024", func(c *net.UDPConn, a *net.UDPAddr, b []byte) { c.WriteToUDP(HELLO_WORLD, a) }) } func Listen(a string, f func(*net.UDPConn, *net.UDPAddr, []byte)) { if address, e := net.ResolveUDPAddr("udp", a); e == nil { if conn, e := net.ListenUDP("udp", address); e == nil { for b := make([]byte, 1024); ; b = make([]byte, 1024) { if n, client, e := conn.ReadFromUDP(b); e == nil { go f(conn, client, b[:n]) } } } } return } go for the would-be network programmer http://103 slides.games-with-brains.net/
  104. 104. package main import "net" func main() { HELLO_WORLD := []byte("Hello Worldn") Listen(":1024", func(c *net.UDPConn, a *net.UDPAddr, b []byte) { c.WriteToUDP(HELLO_WORLD, a) }) } func Listen(a string, f func(*net.UDPConn, *net.UDPAddr, []byte)) { if address, e := net.ResolveUDPAddr("udp", a); e == nil { if conn, e := net.ListenUDP("udp", address); e == nil { for b := make([]byte, 1024); ; b = make([]byte, 1024) { if n, client, e := conn.ReadFromUDP(b); e == nil { go f(conn, client, b[:n]) } } } } return } go for the would-be network programmer http://104 slides.games-with-brains.net/
  105. 105. package main import "net" func main() { HELLO_WORLD := []byte("Hello Worldn") Listen(":1024", func(c *net.UDPConn, a *net.UDPAddr, b []byte) { c.WriteToUDP(HELLO_WORLD, a) }) } func Listen(a string, f func(*net.UDPConn, *net.UDPAddr, []byte)) { if address, e := net.ResolveUDPAddr("udp", a); e == nil { if conn, e := net.ListenUDP("udp", address); e == nil { for b := make([]byte, 1024); ; b = make([]byte, 1024) { if n, client, e := conn.ReadFromUDP(b); e == nil { go f(conn, client, b[:n]) } } } } return } go for the would-be network programmer http://105 slides.games-with-brains.net/
  106. 106. package main import "net" func main() { HELLO_WORLD := []byte("Hello Worldn") Listen(":1024", func(c *net.UDPConn, a *net.UDPAddr, b []byte) { c.WriteToUDP(HELLO_WORLD, a) }) } func Listen(a string, f func(*net.UDPConn, *net.UDPAddr, []byte)) { if address, e := net.ResolveUDPAddr("udp", a); e == nil { if conn, e := net.ListenUDP("udp", address); e == nil { for b := make([]byte, 1024); ; b = make([]byte, 1024) { if n, client, e := conn.ReadFromUDP(b); e == nil { go f(conn, client, b[:n]) } } } } return } go for the would-be network programmer http://106 slides.games-with-brains.net/
  107. 107. package main import "net" func main() { HELLO_WORLD := []byte("Hello Worldn") Listen(":1024", func(c *net.UDPConn, a *net.UDPAddr, b []byte) { c.WriteToUDP(HELLO_WORLD, a) }) } func Listen(a string, f func(*net.UDPConn, *net.UDPAddr, []byte)) { if address, e := net.ResolveUDPAddr("udp", a); e == nil { if conn, e := net.ListenUDP("udp", address); e == nil { for b := make([]byte, 1024); ; b = make([]byte, 1024) { if n, client, e := conn.ReadFromUDP(b); e == nil { go f(conn, client, b[:n]) } } } } return } go for the would-be network programmer http://107 slides.games-with-brains.net/
  108. 108. package main import "bufio" import . "fmt" import "net" func main() { Dial(":1024", func(conn net.Conn) { if _, e := conn.Write([]byte("n")); e == nil { if m, e := bufio.NewReader(conn).ReadString('n'); e == nil { Printf("%v", m) } } }) } func Dial(a string, f func(net.Conn)) { if address, e := net.ResolveUDPAddr("udp", a); e == nil { if conn, e := net.DialUDP("udp", nil, address); e == nil { defer conn.Close() f(conn) } } } go for the would-be network programmer http://108 slides.games-with-brains.net/
  109. 109. package main import "bufio" import . "fmt" import "net" func main() { Dial(":1024", func(conn net.Conn) { if _, e := conn.Write([]byte("n")); e == nil { if m, e := bufio.NewReader(conn).ReadString('n'); e == nil { Printf("%v", m) } } }) } func Dial(a string, f func(net.Conn)) { if address, e := net.ResolveUDPAddr("udp", a); e == nil { if conn, e := net.DialUDP("udp", nil, address); e == nil { defer conn.Close() f(conn) } } } go for the would-be network programmer http://109 slides.games-with-brains.net/
  110. 110. package main import "bufio" import . "fmt" import "net" func main() { Dial(":1024", func(conn net.Conn) { if _, e := conn.Write([]byte("n")); e == nil { if m, e := bufio.NewReader(conn).ReadString('n'); e == nil { Printf("%v", m) } } }) } func Dial(a string, f func(net.Conn)) { if address, e := net.ResolveUDPAddr("udp", a); e == nil { if conn, e := net.DialUDP("udp", nil, address); e == nil { defer conn.Close() f(conn) } } } go for the would-be network programmer http://110 slides.games-with-brains.net/
  111. 111. package main import "bufio" import . "fmt" import "net" func main() { Dial(":1024", func(conn net.Conn) { if _, e := conn.Write([]byte("n")); e == nil { if m, e := bufio.NewReader(conn).ReadString('n'); e == nil { Printf("%v", m) } } }) } func Dial(a string, f func(net.Conn)) { if address, e := net.ResolveUDPAddr("udp", a); e == nil { if conn, e := net.DialUDP("udp", nil, address); e == nil { defer conn.Close() f(conn) } } } go for the would-be network programmer http://111 slides.games-with-brains.net/
  112. 112. package main import "bufio" import . "fmt" import "net" func main() { Dial(":1024", func(conn net.Conn) { if _, e := conn.Write([]byte("n")); e == nil { if m, e := bufio.NewReader(conn).ReadString('n'); e == nil { Printf("%v", m) } } }) } func Dial(a string, f func(net.Conn)) { if address, e := net.ResolveUDPAddr("udp", a); e == nil { if conn, e := net.DialUDP("udp", nil, address); e == nil { defer conn.Close() f(conn) } } } go for the would-be network programmer http://112 slides.games-with-brains.net/
  113. 113. package main import "bufio" import . "fmt" import "net" func main() { Dial(":1024", func(conn net.Conn) { if _, e := conn.Write([]byte("n")); e == nil { if m, e := bufio.NewReader(conn).ReadString('n'); e == nil { Printf("%v", m) } } }) } func Dial(a string, f func(net.Conn)) { if address, e := net.ResolveUDPAddr("udp", a); e == nil { if conn, e := net.DialUDP("udp", nil, address); e == nil { defer conn.Close() f(conn) } } } go for the would-be network programmer http://113 slides.games-with-brains.net/
  114. 114. package main import "bufio" import . "fmt" import "net" func main() { Dial(":1024", func(conn net.Conn) { if _, e := conn.Write([]byte("n")); e == nil { if m, e := bufio.NewReader(conn).ReadString('n'); e == nil { Printf("%v", m) } } }) } func Dial(a string, f func(net.Conn)) { if address, e := net.ResolveUDPAddr("udp", a); e == nil { if conn, e := net.DialUDP("udp", nil, address); e == nil { defer conn.Close() f(conn) } } } go for the would-be network programmer http://114 slides.games-with-brains.net/
  115. 115. package main import "bufio" import . "fmt" import "net" func main() { Dial(":1024", func(conn net.Conn) { if _, e := conn.Write([]byte("n")); e == nil { if m, e := bufio.NewReader(conn).ReadString('n'); e == nil { Printf("%v", m) } } }) } func Dial(a string, f func(net.Conn)) { if address, e := net.ResolveUDPAddr("udp", a); e == nil { if conn, e := net.DialUDP("udp", nil, address); e == nil { defer conn.Close() f(conn) } } } go for the would-be network programmer http://115 slides.games-with-brains.net/
  116. 116. package main import "bufio" import . "fmt" import "net" func main() { Dial(":1024", func(conn net.Conn) { if _, e := conn.Write([]byte("n")); e == nil { if m, e := bufio.NewReader(conn).ReadString('n'); e == nil { Printf("%v", m) } } }) } func Dial(a string, f func(net.Conn)) { if address, e := net.ResolveUDPAddr("udp", a); e == nil { if conn, e := net.DialUDP("udp", nil, address); e == nil { defer conn.Close() f(conn) } } } go for the would-be network programmer http://116 slides.games-with-brains.net/
  117. 117. rsa go for the would-be network programmer 117 http://slides.games-with-brains.net/
  118. 118. package main import "net" func main() { HELLO_WORLD := []byte("Hello Worldn") Listen(":1024", func(c *net.UDPConn, a *net.UDPAddr, b []byte) { c.WriteToUDP(HELLO_WORLD, a) }) } func Listen(a string, f func(*net.UDPConn, *net.UDPAddr, []byte)) { if address, e := net.ResolveUDPAddr("udp", a); e == nil { if conn, e := net.ListenUDP("udp", address); e == nil { for b := make([]byte, 1024); ; b = make([]byte, 1024) { if n, client, e := conn.ReadFromUDP(b); e == nil { go f(conn, client, b[:n]) } } } } return } go for the would-be network programmer http://118 slides.games-with-brains.net/
  119. 119. package main import . "bytes" import "crypto/rsa" import "encoding/gob" import "net" func main() { HELLO_WORLD := []byte("Hello World") RSA_LABEL := []byte("served") Listen(":1025", func(c *net.UDPConn, a *net.UDPAddr, b []byte) { var key rsa.PublicKey if e := gob.NewDecoder(NewBuffer(b)).Decode(&key); e == nil { if m, e := Encrypt(&key, HELLO_WORLD, RSA_LABEL); e == nil { c.WriteToUDP(m, a) } } return }) } go for the would-be network programmer http://119 slides.games-with-brains.net/
  120. 120. package main import . "bytes" import "crypto/rsa" import "encoding/gob" import "net" func main() { HELLO_WORLD := []byte("Hello World") RSA_LABEL := []byte("served") Listen(":1025", func(c *net.UDPConn, a *net.UDPAddr, b []byte) { var key rsa.PublicKey if e := gob.NewDecoder(NewBuffer(b)).Decode(&key); e == nil { if m, e := Encrypt(&key, HELLO_WORLD, RSA_LABEL); e == nil { c.WriteToUDP(m, a) } } return }) } go for the would-be network programmer http://120 slides.games-with-brains.net/
  121. 121. package main import . "bytes" import "crypto/rsa" import "encoding/gob" import "net" func main() { HELLO_WORLD := []byte("Hello World") RSA_LABEL := []byte("served") Listen(":1025", func(c *net.UDPConn, a *net.UDPAddr, b []byte) { var key rsa.PublicKey if e := gob.NewDecoder(NewBuffer(b)).Decode(&key); e == nil { if m, e := Encrypt(&key, HELLO_WORLD, RSA_LABEL); e == nil { c.WriteToUDP(m, a) } } return }) } go for the would-be network programmer http://121 slides.games-with-brains.net/
  122. 122. package main import . "bytes" import "crypto/rsa" import "encoding/gob" import "net" func main() { HELLO_WORLD := []byte("Hello World") RSA_LABEL := []byte("served") Listen(":1025", func(c *net.UDPConn, a *net.UDPAddr, b []byte) { var key rsa.PublicKey if e := gob.NewDecoder(NewBuffer(b)).Decode(&key); e == nil { if m, e := Encrypt(&key, HELLO_WORLD, RSA_LABEL); e == nil { c.WriteToUDP(m, a) } } return }) } go for the would-be network programmer http://122 slides.games-with-brains.net/
  123. 123. package main import . "bytes" import "crypto/rsa" import "encoding/gob" import "net" func main() { HELLO_WORLD := []byte("Hello World") RSA_LABEL := []byte("served") Listen(":1025", func(c *net.UDPConn, a *net.UDPAddr, b []byte) { var key rsa.PublicKey if e := gob.NewDecoder(NewBuffer(b)).Decode(&key); e == nil { if m, e := Encrypt(&key, HELLO_WORLD, RSA_LABEL); e == nil { c.WriteToUDP(m, a) } } return }) } go for the would-be network programmer http://123 slides.games-with-brains.net/
  124. 124. package main import . "bytes" import "crypto/rsa" import "encoding/gob" import "net" func main() { HELLO_WORLD := []byte("Hello World") RSA_LABEL := []byte("served") Listen(":1025", func(c *net.UDPConn, a *net.UDPAddr, b []byte) { var key rsa.PublicKey if e := gob.NewDecoder(NewBuffer(b)).Decode(&key); e == nil { if m, e := Encrypt(&key, HELLO_WORLD, RSA_LABEL); e == nil { c.WriteToUDP(m, a) } } return }) } go for the would-be network programmer http://124 slides.games-with-brains.net/
  125. 125. package main import . "bytes" import "crypto/rsa" import "encoding/gob" import "net" func main() { HELLO_WORLD := []byte("Hello World") RSA_LABEL := []byte("served") Listen(":1025", func(c *net.UDPConn, a *net.UDPAddr, b []byte) { var key rsa.PublicKey if e := gob.NewDecoder(NewBuffer(b)).Decode(&key); e == nil { if m, e := Encrypt(&key, HELLO_WORLD, RSA_LABEL); e == nil { c.WriteToUDP(m, a) } } return }) } go for the would-be network programmer http://125 slides.games-with-brains.net/
  126. 126. package main import . "bytes" import "crypto/rsa" import "encoding/gob" import "net" func main() { HELLO_WORLD := []byte("Hello World") RSA_LABEL := []byte("served") Listen(":1025", func(c *net.UDPConn, a *net.UDPAddr, b []byte) { var key rsa.PublicKey if e := gob.NewDecoder(NewBuffer(b)).Decode(&key); e == nil { if m, e := Encrypt(&key, HELLO_WORLD, RSA_LABEL); e == nil { c.WriteToUDP(m, a) } } return }) } go for the would-be network programmer http://126 slides.games-with-brains.net/
  127. 127. package main import "crypto/rand" import "crypto/rsa" import "crypto/sha1" func Encrypt(key *rsa.PublicKey, m, l []byte) ([]byte, error) { return rsa.EncryptOAEP(sha1.New(), rand.Reader, key, m, l) } go for the would-be network programmer http://127 slides.games-with-brains.net/
  128. 128. package main import "crypto/rand" import "crypto/rsa" import "crypto/sha1" func Encrypt(key *rsa.PublicKey, m, l []byte) ([]byte, error) { return rsa.EncryptOAEP(sha1.New(), rand.Reader, key, m, l) } go for the would-be network programmer http://128 slides.games-with-brains.net/
  129. 129. package main import "crypto/rand" import "crypto/rsa" import "crypto/sha1" func Encrypt(key *rsa.PublicKey, m, l []byte) ([]byte, error) { return rsa.EncryptOAEP(sha1.New(), rand.Reader, key, m, l) } go for the would-be network programmer http://129 slides.games-with-brains.net/
  130. 130. package main import "crypto/rand" import "crypto/rsa" import "crypto/sha1" func Encrypt(key *rsa.PublicKey, m, l []byte) ([]byte, error) { return rsa.EncryptOAEP(sha1.New(), rand.Reader, key, m, l) } go for the would-be network programmer http://130 slides.games-with-brains.net/
  131. 131. package main import "crypto/rand" import "crypto/rsa" import "crypto/sha1" func Encrypt(key *rsa.PublicKey, m, l []byte) ([]byte, error) { return rsa.EncryptOAEP(sha1.New(), rand.Reader, key, m, l) } go for the would-be network programmer http://131 slides.games-with-brains.net/
  132. 132. package main import "crypto/rsa" import . "fmt" import "net" func main() { Dial(":1025", "ckey", func(c *net.UDPConn, k *rsa.PrivateKey) { if m, e := ReadStream(c); e == nil { if m, e := Decrypt(k, m, []byte("served")); e == nil { Println(string(m)) } } }) } go for the would-be network programmer http://132 slides.games-with-brains.net/
  133. 133. package main import "crypto/rsa" import . "fmt" import "net" func main() { Dial(":1025", "ckey", func(c *net.UDPConn, k *rsa.PrivateKey) { if m, e := ReadStream(c); e == nil { if m, e := Decrypt(k, m, []byte("served")); e == nil { Println(string(m)) } } }) } go for the would-be network programmer http://133 slides.games-with-brains.net/
  134. 134. package main import "crypto/rsa" import . "fmt" import "net" func main() { Dial(":1025", "ckey", func(c *net.UDPConn, k *rsa.PrivateKey) { if m, e := ReadStream(c); e == nil { if m, e := Decrypt(k, m, []byte("served")); e == nil { Println(string(m)) } } }) } go for the would-be network programmer http://134 slides.games-with-brains.net/
  135. 135. package main import "crypto/rand" import "crypto/rsa" import "crypto/sha1" func Decrypt(key *rsa.PrivateKey, m, l []byte) ([]byte, error) { return rsa.DecryptOAEP(sha1.New(), rand.Reader, key, m, l) } go for the would-be network programmer http://135 slides.games-with-brains.net/
  136. 136. package main import "crypto/rsa" import . "fmt" import "net" func main() { Dial(":1025", "ckey", func(c *net.UDPConn, k *rsa.PrivateKey) { if m, e := ReadStream(c); e == nil { if m, e := Decrypt(k, m, []byte("served")); e == nil { Println(string(m)) } } }) } go for the would-be network programmer http://136 slides.games-with-brains.net/
  137. 137. package main import "net" func ReadStream(conn *net.UDPConn) (r []byte, e error) { m := make([]byte, 1024) var n int if n, e = conn.Read(m); e == nil { r = m[:n] } return } go for the would-be network programmer http://137 slides.games-with-brains.net/
  138. 138. package main import "net" func ReadStream(conn *net.UDPConn) (r []byte, e error) { m := make([]byte, 1024) var n int if n, e = conn.Read(m); e == nil { r = m[:n] } return } go for the would-be network programmer http://138 slides.games-with-brains.net/
  139. 139. package main import "net" func ReadStream(conn *net.UDPConn) (r []byte, e error) { m := make([]byte, 1024) var n int if n, e = conn.Read(m); e == nil { r = m[:n] } return } go for the would-be network programmer http://139 slides.games-with-brains.net/
  140. 140. package main import "net" func ReadStream(conn *net.UDPConn) (r []byte, e error) { m := make([]byte, 1024) var n int if n, e = conn.Read(m); e == nil { r = m[:n] } return } go for the would-be network programmer http://140 slides.games-with-brains.net/
  141. 141. package main import "crypto/rsa" import . "fmt" import "net" func main() { Dial(":1025", "ckey", func(c *net.UDPConn, k *rsa.PrivateKey) { if m, e := ReadStream(c); e == nil { if m, e := Decrypt(k, m, []byte("served")); e == nil { Println(string(m)) } } }) } go for the would-be network programmer http://141 slides.games-with-brains.net/
  142. 142. package main import "crypto/rsa" import . "fmt" import "net" func Dial(a, file string, f func(*net.UDPConn, *rsa.PrivateKey)) { if k, e := LoadPrivateKey(file); e == nil { if address, e := net.ResolveUDPAddr("udp", a); e == nil { if conn, e := net.DialUDP("udp", nil, address); e == nil { defer conn.Close() SendKey(conn, k.PublicKey, func() { f(conn, k) }) } } } } go for the would-be network programmer http://142 slides.games-with-brains.net/
  143. 143. package main import "crypto/rsa" import . "fmt" import "net" func Dial(a, file string, f func(*net.UDPConn, *rsa.PrivateKey)) { if k, e := LoadPrivateKey(file); e == nil { if address, e := net.ResolveUDPAddr("udp", a); e == nil { if conn, e := net.DialUDP("udp", nil, address); e == nil { defer conn.Close() SendKey(conn, k.PublicKey, func() { f(conn, k) }) } } } } go for the would-be network programmer http://143 slides.games-with-brains.net/
  144. 144. package main import "crypto/rsa" import . "fmt" import "net" func Dial(a, file string, f func(*net.UDPConn, *rsa.PrivateKey)) { if k, e := LoadPrivateKey(file); e == nil { if address, e := net.ResolveUDPAddr("udp", a); e == nil { if conn, e := net.DialUDP("udp", nil, address); e == nil { defer conn.Close() SendKey(conn, k.PublicKey, func() { f(conn, k) }) } } } } go for the would-be network programmer http://144 slides.games-with-brains.net/
  145. 145. package main import "crypto/rsa" import "crypto/x509" import "encoding/pem" import "io/ioutil" func LoadPrivateKey(file string) (r *rsa.PrivateKey, e error) { if file, e := ioutil.ReadFile(file); e == nil { if block, _ := pem.Decode(file); block != nil { if block.Type == "RSA PRIVATE KEY" { r, e = x509.ParsePKCS1PrivateKey(block.Bytes) } } } return } go for the would-be network programmer http://145 slides.games-with-brains.net/
  146. 146. package main import "crypto/rsa" import "crypto/x509" import "encoding/pem" import "io/ioutil" func LoadPrivateKey(file string) (r *rsa.PrivateKey, e error) { if file, e := ioutil.ReadFile(file); e == nil { if block, _ := pem.Decode(file); block != nil { if block.Type == "RSA PRIVATE KEY" { r, e = x509.ParsePKCS1PrivateKey(block.Bytes) } } } return } go for the would-be network programmer http://146 slides.games-with-brains.net/
  147. 147. package main import "crypto/rsa" import "crypto/x509" import "encoding/pem" import "io/ioutil" func LoadPrivateKey(file string) (r *rsa.PrivateKey, e error) { if file, e := ioutil.ReadFile(file); e == nil { if block, _ := pem.Decode(file); block != nil { if block.Type == "RSA PRIVATE KEY" { r, e = x509.ParsePKCS1PrivateKey(block.Bytes) } } } return } go for the would-be network programmer http://147 slides.games-with-brains.net/
  148. 148. package main import "crypto/rsa" import "crypto/x509" import "encoding/pem" import "io/ioutil" func LoadPrivateKey(file string) (r *rsa.PrivateKey, e error) { if file, e := ioutil.ReadFile(file); e == nil { if block, _ := pem.Decode(file); block != nil { if block.Type == "RSA PRIVATE KEY" { r, e = x509.ParsePKCS1PrivateKey(block.Bytes) } } } return } go for the would-be network programmer http://148 slides.games-with-brains.net/
  149. 149. package main import "crypto/rsa" import "crypto/x509" import "encoding/pem" import "io/ioutil" func LoadPrivateKey(file string) (r *rsa.PrivateKey, e error) { if file, e := ioutil.ReadFile(file); e == nil { if block, _ := pem.Decode(file); block != nil { if block.Type == "RSA PRIVATE KEY" { r, e = x509.ParsePKCS1PrivateKey(block.Bytes) } } } return } go for the would-be network programmer http://149 slides.games-with-brains.net/
  150. 150. package main import "crypto/rsa" import "crypto/x509" import "encoding/pem" import "io/ioutil" func LoadPrivateKey(file string) (r *rsa.PrivateKey, e error) { if file, e := ioutil.ReadFile(file); e == nil { if block, _ := pem.Decode(file); block != nil { if block.Type == "RSA PRIVATE KEY" { r, e = x509.ParsePKCS1PrivateKey(block.Bytes) } } } return } go for the would-be network programmer http://150 slides.games-with-brains.net/
  151. 151. package main import "crypto/rsa" import . "fmt" import "net" func Dial(a, file string, f func(*net.UDPConn, *rsa.PrivateKey)) { if k, e := LoadPrivateKey(file); e == nil { if address, e := net.ResolveUDPAddr("udp", a); e == nil { if conn, e := net.DialUDP("udp", nil, address); e == nil { defer conn.Close() SendKey(conn, k.PublicKey, func() { f(conn, k) }) } } } } go for the would-be network programmer http://151 slides.games-with-brains.net/
  152. 152. package main import "crypto/rsa" import . "fmt" import "net" func Dial(a, file string, f func(*net.UDPConn, *rsa.PrivateKey)) { if k, e := LoadPrivateKey(file); e == nil { if address, e := net.ResolveUDPAddr("udp", a); e == nil { if conn, e := net.DialUDP("udp", nil, address); e == nil { defer conn.Close() SendKey(conn, k.PublicKey, func() { f(conn, k) }) } } } } go for the would-be network programmer http://152 slides.games-with-brains.net/
  153. 153. package main import "crypto/rsa" import . "fmt" import "net" func Dial(a, file string, f func(*net.UDPConn, *rsa.PrivateKey)) { if k, e := LoadPrivateKey(file); e == nil { if address, e := net.ResolveUDPAddr("udp", a); e == nil { if conn, e := net.DialUDP("udp", nil, address); e == nil { defer conn.Close() SendKey(conn, k.PublicKey, func() { f(conn, k) }) } } } } go for the would-be network programmer http://153 slides.games-with-brains.net/
  154. 154. package main import "bytes" import “crypto/rsa" import "encoding/gob" import "net" func SendKey(c *net.UDPConn, k rsa.PublicKey, f func()) { var b bytes.Buffer if e := gob.NewEncoder(&b).Encode(k); e == nil { if _, e = c.Write(b.Bytes()); e == nil { f() } } } go for the would-be network programmer http://154 slides.games-with-brains.net/
  155. 155. package main import "bytes" import “crypto/rsa" import "encoding/gob" import "net" func SendKey(c *net.UDPConn, k rsa.PublicKey, f func()) { var b bytes.Buffer if e := gob.NewEncoder(&b).Encode(k); e == nil { if _, e = c.Write(b.Bytes()); e == nil { f() } } } go for the would-be network programmer http://155 slides.games-with-brains.net/
  156. 156. package main import "bytes" import “crypto/rsa" import "encoding/gob" import "net" func SendKey(c *net.UDPConn, k rsa.PublicKey, f func()) { var b bytes.Buffer if e := gob.NewEncoder(&b).Encode(k); e == nil { if _, e = c.Write(b.Bytes()); e == nil { f() } } } go for the would-be network programmer http://156 slides.games-with-brains.net/
  157. 157. package main import "crypto/rsa" import . "fmt" import "net" func Dial(a, file string, f func(*net.UDPConn, *rsa.PrivateKey)) { if k, e := LoadPrivateKey(file); e == nil { if address, e := net.ResolveUDPAddr("udp", a); e == nil { if conn, e := net.DialUDP("udp", nil, address); e == nil { defer conn.Close() SendKey(conn, k.PublicKey, func() { f(conn, k) }) } } } } go for the would-be network programmer http://157 slides.games-with-brains.net/
  158. 158. http://golang.org/ go for the would-be network programmer http://158 slides.games-with-brains.net/
  159. 159. twitter://#golang go for the would-be network programmer http://159 slides.games-with-brains.net/

×