func (s *Socket) Write(buf []byte) error {
	for len(buf) > 0 {
		n, err := syscall.Write(s.fd, buf)
		if err != nil {
			return err
		}
		buf = buf[n:]
	}
	return nil
}
Write all given data to the specified socket.
package lib
import "C"
import (
	"bufio"
	"image"
	"sync"
	"syscall"
	"time"
	"changkun.de/x/occamy/protocol"
)
type Socket struct {
	guacSocket *C.struct_guac_socket
	once       sync.Once
	fd        int
	reader    *bufio.Reader
	writer    *bufio.Writer
	lastWrite time.Time
	readyBuf  []byte
	IsOpen    bool
	data      interface{}
}
func NewSocket(fd int) (*Socket, error) {
	guacSocket := C.guac_socket_open(C.int(fd))
	if guacSocket == nil {
		return nil, errorStatus()
	}
	conn := protocol.NewIO(fd)
	return &Socket{
		fd:         fd,
		guacSocket: guacSocket,
		reader:     bufio.NewReader(conn),
		writer:     bufio.NewWriter(conn),
	}, nil
}
func (s *Socket) Close() {
	s.once.Do(func() {
		syscall.Close(s.fd)
		C.guac_socket_free(s.guacSocket)
	})
}
func (s *Socket) Read(buf []byte) (int, error) {
	return syscall.Read(s.fd, buf)
}