mirror of
https://github.com/jixishi/SerialTerminalForWindowsTerminal.git
synced 2026-06-16 00:52:44 +00:00
TCP|UDP 客户端数据转发支持更新
This commit is contained in:
@@ -1,16 +1,54 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"log"
|
||||
"net"
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
portName string
|
||||
baudRate int
|
||||
dataBits int
|
||||
stopBits int
|
||||
parityBit int
|
||||
outputCode string
|
||||
inputCode string
|
||||
endStr string
|
||||
enableLog bool
|
||||
logFilePath string
|
||||
parityBit int
|
||||
forWard int
|
||||
address string
|
||||
}
|
||||
type FoeWardMode int
|
||||
|
||||
const (
|
||||
NOT FoeWardMode = iota
|
||||
TCPS
|
||||
TCPC
|
||||
UDPS
|
||||
UDPC
|
||||
)
|
||||
|
||||
var config Config
|
||||
|
||||
func setForWard() (conn net.Conn) {
|
||||
switch FoeWardMode(config.forWard) {
|
||||
case TCPS:
|
||||
|
||||
case TCPC:
|
||||
conn, err = net.Dial("tcp", config.address)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
case UDPS:
|
||||
|
||||
case UDPC:
|
||||
conn, err = net.Dial("udp", config.address)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
default:
|
||||
panic("未知模式设置")
|
||||
}
|
||||
return conn
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user