import (
"fmt"
"net"
"os"
)
const (
connHost = "localhost"
connPort = "8000"
connType = "tcp"
)
func main() {
// Connect to the server
conn, err := net.Dial(connType, connHost+":"+connPort)
if err != nil {
fmt.Println("Error connecting:", err.Error())
os.Exit(1)
}
// Send some data
_, err = conn.Write([]byte("Hello Server!"))
if err != nil {
fmt.Println("Error writing:", err.Error())
os.Exit(1)
}
// Receive some data
buffer := make([]byte, 1024)
n, err := conn.Read(buffer)
if err != nil {
fmt.Println("Error reading:", err.Error())
os.Exit(1)
}
// Print the received data
fmt.Println("Received:", string(buffer[:n]))
// Close the connection
conn.Close()
}
다음 내용이 궁금하다면?
이미 회원이신가요?
2023년 11월 15일 오전 7:35
순수하게 chatgpt가 짜줌 나는 어떠한 모듈을 쓸 것인가만 요청함
그래서 난 이 코드 해석 못함