- Go Web Development Cookbook
- Arpit Aggarwal
- 112字
- 2021-08-27 19:01:14
How it works…
Once we run the program, the TCP server will start locally listening on port 8080. Execute an echo command from the command line, as follows:
$ echo -n "Hello to TCP server\n" | nc localhost 8080
This will give us the following response from the server:
Hello to TCP server
Let’s look at the changes we introduced in this recipe to write data to the client. Everything in handleRequest is exactly the same as in the previous recipe except we introduced a new line that writes data as a byte array to the connection, as follows:
func handleRequest(conn net.Conn)
{
...
conn.Write([]byte(message + "\n"))
...
}
推薦閱讀
- GPS/GNSS原理與應用(第3版)
- 物聯網信息安全
- 互聯網基礎資源技術與應用發展態勢(2021—2023)
- Windows Server 2003 Active Directory Design and Implementation: Creating, Migrating, and Merging Networks
- NB-IoT物聯網技術解析與案例詳解
- Getting Started with Grunt:The JavaScript Task Runner
- 物聯網技術與應用
- Microsoft Dynamics CRM 2011 Applications(MB2-868) Certification Guide
- 物聯網場景設計與開發(初級)
- 移動互聯網新思維
- Cisco無線局域網配置基礎
- Migrating to Drupal7
- 5G新型多址技術
- 國外物聯網透視
- Mastering Prezi for Business Presentations