connection.go 635 B

12345678910111213141516171819202122232425262728293031323334353637
  1. package internet
  2. import (
  3. "net"
  4. )
  5. type ConnectionHandler func(Connection)
  6. type Reusable interface {
  7. Reusable() bool
  8. SetReusable(reuse bool)
  9. }
  10. type StreamConnectionType int
  11. var (
  12. StreamConnectionTypeRawTCP StreamConnectionType = 1
  13. StreamConnectionTypeTCP StreamConnectionType = 2
  14. StreamConnectionTypeKCP StreamConnectionType = 4
  15. )
  16. type StreamSettings struct {
  17. Type StreamConnectionType
  18. }
  19. func (this *StreamSettings) IsCapableOf(streamType StreamConnectionType) bool {
  20. return (this.Type & streamType) == streamType
  21. }
  22. type Connection interface {
  23. net.Conn
  24. Reusable
  25. }
  26. type SysFd interface {
  27. SysFd() (int, error)
  28. }