This is a creation in Article, where the information may have evolved or changed.
The code is as follows:
</pre><pre>package mainimport ("Bufio" "FMT" "NET" "OS" "Time") const (Head = 4) var (clientmap map[int]net. Conn = Make (map[int]net. Conn)) Func main () {FMT. Println (OS. Args[0]) Ip_port: = "127.0.0.1:843" If Len (OS. Args) > 1 {ip_port = OS. Args[1]}fmt. Println ("\nflash as policy service running ... \ n" automatically responds to crossdomain.xml requests for socketxml ports (i.e. 843 ports) \ n to specify the IP and port, you can specify the parameters when the program starts, in the following format \ Ngameserver843.exe 192.168.101.139:843 "," \ n currently listening ", Ip_port," \ n please do not close this window ... ") tcpaddr, err: = Net. RESOLVETCPADDR ("TCP4", Ip_port) checkerror (ERR) listener, err: = Net. LISTENTCP ("TCP", TCPADDR) checkerror (err) Clientindex: = 0for {clientindex++conn, err: = Listener. Accept () if err! = Nil {Continue}go handleclient (conn, clientindex)}}func handleclient (conn net. Conn, index int) {Clientmap[index] = connfmt. Println ("") fmt. Println ("=======================") fmt. PRINTLN ("New user connection, from:", Conn.) Remoteaddr (), "Index:", index) FC: = Func () {time. Sleep (time. Second)//give the client 1 seconds of response time, otherwise the client may not be able to read the data in advance Close the Conn.close () Delete (Clientmap, index) FMT. PRINTLN ("Remove serial number as:", Index," client, disconnects the client ") FMT. Println ("=======================")}defer FC () SENDFIRSTMSG (conn)}func SENDFIRSTMSG (conn net. Conn) {str: = ' <?xml version= ' 1.0 '? ><! DOCTYPE cross-domain-policy SYSTEM "/xml/dtds/cross-domain-policy.dtd" ><cross-domain-policy>< Site-control permitted-cross-domain-policies= "master-only"/><allow-access-from domain= "*" to-ports= "*"/> </cross-domain-policy> ' Writer: = Bufio. Newwriter (conn) writer. WriteString (str) writer. Flush () fmt. Println ("Already responded policy file: Crossdomain.xml")}func checkerror (err error) {if err! = Nil {fmt. Println (Err. Error ()) OS. Exit (1)}}
Install the Golang environment, then go directly to run Main.go on the line.
Of course, you can also download my compiled exe executable file directly.
The download page is as follows:
https://github.com/moketao/XmlSocket_843