Git Product home page Git Product logo

Comments (1)

yukixz avatar yukixz commented on July 27, 2024

你需要发 clienthello 向酷q端注册、并且两分钟发一次保证不会被酷q端移除

On Monday, 8 August 2016, linexjlin [email protected] wrote:

根据readme 用go写了个client, 可以发送消息,可是接不到消息。

// udp_client project main.go
package main

import (
"fmt"
"net"
//"strconv"
//"encoding/base64"
"strings"
"time"
)

func main() {
begin:
s, e := net.DialUDP("udp4",
&net.UDPAddr{
IP: net.IPv4(127, 0, 0, 1),
Port: 11236,
},
&net.UDPAddr{
IP: net.IPv4(127, 0, 0, 1),
Port: 11235,
})

if e != nil {
    fmt.Println(e)
    goto begin
}

fmt.Println("success connect to local upd 11253 ")

fmt.Println("localAddr:", s.LocalAddr().String())
lPort := strings.Split(s.LocalAddr().String(), ":")[1]
fmt.Println(lPort)
// send routine
go func() {
    for {
        n, e := s.Write([]byte("ClientHello " + lPort))
        if e != nil {
            fmt.Println(e)
        }

        fmt.Println("write ", n, "message to", s.RemoteAddr().String())

        time.Sleep(time.Second * 20)
    }
}()

go func() {
    for {
        time.Sleep(time.Second * 5)
        n, e := s.Write([]byte(`PrivateMessage 379667034 dGVzdCCy4srU`))
        //n, e := s.Write([]byte(`PrivateMessage 379667034 dGVzdCDmtYvor5U=`))

        if e != nil {
            fmt.Println(e)
        }

        fmt.Println("write ", n, "message to", s.RemoteAddr().String())

        //time.Sleep(time.Second * 5)
    }
}()

// 接收routine
go func() {
    for {
        fmt.Println("wait for message from server...")
        buf := make([]byte, 8)
        n, _ := s.Read(buf)
        fmt.Println("receive", n, "bytes message\n the message is:", string(buf))
    }
}()

//wait routine
for {
    time.Sleep(time.Second * 3)
}

}


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
#4, or mute the thread
https://github.com/notifications/unsubscribe-auth/ADLuwZpupCmjF-tVcpvSWspSqgd0QROEks5qdhVTgaJpZM4Jei10
.

Dazzy Ding
Email: [email protected]

from cqsocketapi.

Related Issues (13)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.