mirror of
https://github.com/yv1ing/rdp_channel.git
synced 2025-09-16 14:59:08 +08:00
完成TPKT、X224、FastPath协议基本封装和测试
This commit is contained in:
38
app/client.go
Normal file
38
app/client.go
Normal file
@@ -0,0 +1,38 @@
|
||||
package app
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"net"
|
||||
"rdp_channel/protocol"
|
||||
"time"
|
||||
)
|
||||
|
||||
type Client struct {
|
||||
Host string
|
||||
Port int
|
||||
}
|
||||
|
||||
func NewClient(host string, port int) Client {
|
||||
return Client{host, port}
|
||||
}
|
||||
|
||||
func (client Client) Start() error {
|
||||
addr := fmt.Sprintf("%s:%d", client.Host, client.Port)
|
||||
|
||||
conn, err := net.Dial("tcp", addr)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer conn.Close()
|
||||
log.Println("[Client] connected to " + addr)
|
||||
|
||||
tpkt := protocol.NewTPKT(conn)
|
||||
//fast := protocol.NewFastPath(conn)
|
||||
//x224 := protocol.NewX224(conn)
|
||||
|
||||
for {
|
||||
time.Sleep(1 * time.Second)
|
||||
err = tpkt.Write([]byte("This is a test message."))
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user