Socket transfer single link and multi-connection test results between servers

Source: Internet
Author: User

Today, I did a test to see if server A in LAN is transmitting data through a connection to Server B, and it is different from multiple connections.

Results found and how many connections do not matter, a process a connection can run full network card, as long as the write time is fast enough, read time is fast enough. 1000m network card, TCP can run to 910m

Here are the programs written by Golang:

Server

Package Main
Import (
"FMT"
"NET"
"OS"
)
Func Main () {
L, Err: = Net. Listen ("TCP", OS. ARGS[1])
If err! = Nil {
Fmt. Println ("Error Listening:", err.) Error ())
Os. Exit (1)
}
Defer L.close ()
Fmt. Println ("Listening on:" + OS. ARGS[1])
for {
Conn, err: = L.accept ()
If err! = Nil {
Fmt. Println ("Error accepting:", err.) Error ())
Os. Exit (1)
}
Go HandleRequest (conn)
}
}
Func HandleRequest (Conn net. Conn) {
BUF: = make ([]byte,209715200)
for {
_, ERR: = conn. Read (BUF)
If err! = Nil {
Fmt. PRINTLN (ERR)
Return
}
}
}

Client

Package Main
Import "NET"
Import "OS"
Import "Log"
Import "StrConv"
Func Main () {
Conn, Err: = Net. Dial ("TCP", OS. ARGS[1])
i64, err1: = StrConv. parseint (OS. ARGS[2], 10, 32)
If Err!=nil {
Log. PRINTLN (ERR)
}
If err1!=nil{
Log. Println (ERR1)
}
200m=209715200
var array = make ([]byte,i64)
for {
Conn. Write (array[:])
}
}

Socket transfer single link and multi-connection test results between servers

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.