accept.go 577 B

12345678910111213141516171819202122232425262728293031323334353637
  1. package goSam
  2. import (
  3. "fmt"
  4. "net"
  5. "github.com/cryptix/go/debug"
  6. )
  7. // Accept creates a new Client and accepts a connection on it
  8. func (c *Client) Accept() (net.Conn, error) {
  9. id, newAddr, err := c.CreateStreamSession("")
  10. if err != nil {
  11. return nil, err
  12. }
  13. fmt.Println("NewAddr:", newAddr)
  14. newC, err := NewDefaultClient()
  15. if err != nil {
  16. return nil, err
  17. }
  18. if c.debug {
  19. newC.SamConn = debug.WrapConn(newC.SamConn)
  20. }
  21. resp, err := newC.StreamAccept(id)
  22. if err != nil {
  23. return nil, err
  24. }
  25. fmt.Println("Accept Resp:", resp)
  26. return newC.SamConn, nil
  27. }