gitee.com/sy_183/go-common@v1.0.5-0.20231205030221-958cfe129b47/ipc/cgo/smp/conn.go (about)

     1  package smp
     2  
     3  import (
     4  	"gitee.com/sy_183/go-common/ipc/cgo/sem/queue"
     5  	shmPkg "gitee.com/sy_183/go-common/ipc/cgo/shm"
     6  	"net"
     7  	"time"
     8  )
     9  
    10  type Conn struct {
    11  	listener *Listener
    12  	uc       *net.UnixConn
    13  
    14  	shm *shmPkg.Shm
    15  	raw []byte
    16  
    17  	q *queue.Queue32
    18  	c chan queue.Queue32View
    19  }
    20  
    21  func (c *Conn) run() {
    22  	defer func() {
    23  		if c.q != nil {
    24  			c.listener.unregisterSelect(c)
    25  		}
    26  	}()
    27  
    28  	buf := make([]byte, maxPacketLength)
    29  	basePacket := BasePacket{}
    30  	for {
    31  		n, err := c.uc.Read(buf)
    32  		if err != nil {
    33  			return
    34  		}
    35  		data := buf[:n]
    36  		basePacket.Unmarshal(data)
    37  	}
    38  }
    39  
    40  func (c *Conn) read() {
    41  	view := <-c.c
    42  
    43  }
    44  
    45  func (c *Conn) Read(b []byte) (n int, err error) {
    46  
    47  }
    48  
    49  func (c *Conn) Write(b []byte) (n int, err error) {
    50  
    51  }
    52  
    53  func (c *Conn) Close() error {
    54  	c.uc.Close()
    55  }
    56  
    57  func (c *Conn) LocalAddr() net.Addr {
    58  	return c.uc.LocalAddr()
    59  }
    60  
    61  func (c *Conn) RemoteAddr() net.Addr {
    62  	return c.uc.RemoteAddr()
    63  }
    64  
    65  func (c *Conn) SetDeadline(t time.Time) error {
    66  	//TODO implement me
    67  	panic("implement me")
    68  }
    69  
    70  func (c *Conn) SetReadDeadline(t time.Time) error {
    71  	//TODO implement me
    72  	panic("implement me")
    73  }
    74  
    75  func (c *Conn) SetWriteDeadline(t time.Time) error {
    76  	//TODO implement me
    77  	panic("implement me")
    78  }