Giter Site home page Giter Site logo

kcp-cpp's People

Contributors

andersc avatar magnusedgeware avatar tomasoh-edgeware avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

kcp-cpp's Issues

When receiving a relatively large data packet (larger than 8192), the last packet will block for 8 to 10 seconds at mKissnetSocket.recv(receiveBuffer).

When receiving a relatively large data packet (larger than 8192), the last packet will block for 8 to 10 seconds at mKissnetSocket.recv(receiveBuffer).

        const uint64_t tickStart = GetTickCount64(); 
        auto[received_bytes, status] = mKissnetSocket.recv(receiveBuffer); 
        const auto tick = GetTickCount64() - tickStart;
        if (tick > 1000) {
            KCP_LOGGER(false, LOGG_NOTIFY, "Recv Time:  " << tick);   // <----------  10 Second !!!!
        }

The server is developed using kcp-go with the following parameters:

    kcpConn.SetNoDelay(1, 10,2,1)
    kcpConn.SetWindowSize(128, 128)

kcp-cpp:

	KCPSettings lSettingsClient;
	lSettingsClient.mNoDelay = true;
	lSettingsClient.mInterval = 10;
	lSettingsClient.mResend = 2;
	lSettingsClient.mFlow = false;
	lSettingsClient.mMtu = 1400;
	lSettingsClient.mSndWnd = 128;
	lSettingsClient.mRcvWnd = 128;

VS2022 Run Test Error

KCP-cpp test
Connecting IP:port > 127.0.0.1:61263
The server is not active.
The server timed out a client.

can support kcp-go?

I try to use this main.cpp to connect kcp-go(golang) server,But failed

kcp-go can't accept any data from client

and kcp-go send data to client,but client can't get any data

main.cpp:
`KCPNetClient lKcpClient;

KCPSettings lSettingsClient;
if(lKcpClient.configureKCP(lSettingsClient,
                           gotDataClient,
                           noConnectionClient,
                           "127.0.0.1",
                           12345,
                           10,
                           nullptr)) {
    std::cout << "Failed to configure the KCP Client" << std::endl;
}

lKcpClient.sendData((const char*)lData.data(), 4000);`

main.go:
`package main

import (
"log"

"github.com/xtaci/kcp-go/v5"

)

func main() {

if listener, err := kcp.ListenWithOptions("127.0.0.1:12345", nil, 10, 3); err == nil {
    // spin-up the client
    for {
        s, err := listener.AcceptKCP()
        s.SetNoDelay(1, 10, 2, 1)
        if err != nil {
            log.Fatal(err)
        }
        go handleEcho(s)
    }
} else {
    log.Fatal(err)
}

}

// handleEcho send back everything it received
func handleEcho(conn *kcp.UDPSession) {
buf := make([]byte, 4096)
for {
n, err := conn.Read(buf)
if err != nil {
log.Println(err)
return
}
println("get:" + string(buf[:n]))
n, err = conn.Write(buf[:n])
if err != nil {
log.Println(err)
return
}
}
}
`

How to auto reconnect to kcp server?

I found that after the kcpClient triggers the disconnection (noConnectionClient), when I call sendData again to send data, there is no response in the gotDataClient callback function after the server responds.

Network thread

In the KCP NetServer::netWorkerServer function, we start a network thread and exit if there are no incoming messages. That is, when the server starts, it will shut down. This is very strange, considering that the server must work constantly and wait for clients to connect

    while (true) {
        auto[received_bytes, status] = mKissnetSocket.recv(receiveBuffer,0, &receiveConnection);
        if (!received_bytes || status != kissnet::socket_status::valid) {
            KCP_LOGGER(false, LOGG_NOTIFY, "serverWorker quitting");
            break;
        }

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.