当前位置:网站首页>[golang] network connection net.dial
[golang] network connection net.dial
2022-07-29 01:51:00 【JavaPub-rodert】
Blogger introduction : We-Media JavaPub Independent maintainer , Fans all over the Internet 15w+,csdn Blogger 、java Quality creators in the field ,51ctoTOP10 Blogger , You know / Nuggets / Hua Wei Yun / Alibaba cloud /InfoQ And other high-quality authors 、 Focus on Java、
GoLangTechnical fields and sidelines .GoLang More convenient to learn , One article in hand , I have
GoLang interview | GoLang interview | GoLang interview
List of articles
Use chestnuts
conn, err := net.Dial("tcp", "google.com:80")
if err != nil {
// handle error
}
fmt.Fprintf(conn, "GET / HTTP/1.0\r\n\r\n")
status, err := bufio.NewReader(conn).ReadString('\n')
// ...
Source code
net.Dial Source code
// net.Dial Function interpretation
// The actual is Dialer.Dial An encapsulation of , After encapsulation , Can be called directly Dial dial , There is no need to define another Dialer Structure object , Use object dialing , The definition of structure object is omitted , The same name method used in packaging , Easy to remember
func Dial(network, address string) (Conn, error) {
var d Dialer // Defined a Dialer Structure object , Use the Dial Method to dial , therefore net.Dial The actual is Dialer.Dial An encapsulation of
return d.Dial(network, address)
}
usage
All in all ,dial Just made some presets , And a connection object is returned .
On the Internet network Upper connection address address, And return a Conn Interface .
Available network types : “tcp”、“tcp4”、“tcp6”、“udp”、“udp4”、“udp6”、“ip”、“ip4”、“ip6”、“unix”、“unixgram”、“unixpacket”
https://www.apiref.com/go-zh/net.htm#Dial


边栏推荐
- 【7.27】代码源 - 【删数】【括号序列】【数字替换】【游戏】【画画】
- Network security litigation risk: four issues that chief information security officers are most concerned about
- 【GoLang】网络连接 net.Dial
- PCL point cloud intensity image
- 【7.21-26】代码源 - 【体育节】【丹钓战】【最大权值划分】
- Some summaries of ibatis script and provider
- matplotlib中文问题
- Timer of BOM series
- Platofarm community ecological gospel, users can get premium income with elephant swap
- J9 number theory: what factors determine the value of NFT?
猜你喜欢
随机推荐
Window object of BOM series
[7.21-26] code source - [square count] [dictionary order minimum] [Z-type matrix]
【10点公开课】:快手GPU/FPGA/ASIC异构平台的应用探索
The brutal rule of blackmail software continues, and attacks increase by 105%
JVM learning minutes
Internship: tool class writing for type judgment
How to choose professional, safe and high-performance remote control software
【搜索】—— DFS之剪枝与优化
Pinduoduo can use many API interfaces
MPEG音频编码三十年
Leetcode 112: path sum
Super technology network security risk assessment service, comprehensively understand the security risks faced by the network system
Platofarm community ecological gospel, users can get premium income with elephant swap
[search] - DFS pruning and optimization
【7.21-26】代码源 - 【体育节】【丹钓战】【最大权值划分】
【流放之路-第八章】
numpy.where() 用法和np.argsort()的用法
About df['a column name'] [serial number]
数据库的decimal类型的数据,发现可以通过resultSet.getDouble去拿到这个数据,但是通过getObject却拿不到这个属性。
For a safer experience, Microsoft announced the first PC with a secure Pluto chip


![[WesternCTF2018]shrine](/img/c1/c099f8930902197590052630281258.png)



![关于df[‘某一列名’][序号]](/img/e2/179fb4eda695726e87bb483f65e04e.png)


![[网鼎杯 2020 朱雀组]Nmap](/img/22/1fdf716a216ae26b9110b2e5f211f6.png)
