Code Monkey home page Code Monkey logo

awesomesockets's People

Contributors

jonlt avatar nterry 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  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

awesomesockets's Issues

Few Questions

Stumbled on this library, looks very minimalist (which is great). I think I have a general Idea how to move forward and integrate this into my applications transport layer. That said, I have a few questions.

ISocketModifier, what is it ?

OnConnect / OnDisconnect events. This does not look implemented. I guess, I will need to implement a simple handshake and a heartbeat myself.

TcpAccept Memory Leak

I just started checking out AwesomeSockets, so far so good.

One issue....

I'm attempting to make it so the Server can have multiple clients connected at once... To do that, it has to be constantly checking for new connections... I do that like this....

      private ServerClass()
      {
         ISocket listenSocket = AweSock.TcpListen(14804);

         // Create a new thread for listening for connections
         new Thread(() =>
            {
               while (true)
               {
                  ISocket socket = AweSock.TcpAccept(
                     listenSocket, 
                     SocketCommunicationTypes.NonBlocking, 
                     ConnectionCallBack);
               }
            }).Start();
      }

      private Socket ConnectionCallBack(ISocket socket, Exception exception)
      {
         // Do stuff...
         return socket.GetSocket();
      }

The issue is when I try to make it NonBlocking & use the callback, it seems to constantly grow in size (until an out of memory exception is thrown). Without the NonBlocking it works fine. Like so...

         new Thread(() =>
            {
               while (true)
               {
                  ISocket socket = AweSock.TcpAccept(
                     listenSocket);
                  if(socket != null)
                  {
                     ConnectionCallBack(socket, null);
                  }
               }
            }).Start();

Compatibility with .NET Core?

error: Package AwesomeSockets 1.4.19 is not compatible with netcoreapp1.1 (.NETCoreApp,Version=v1.1). Package AwesomeSockets 1.4.19 supports: net40 (.NETFramework,Version=v4.0)
error: One or more packages are incompatible with .NETCoreApp,Version=v1.1.

Would be great to have a sockets library that works with Core. Not many do yet.

Timeout support?

Maybe I don't see it but is there support for timeout when read data?

How can i use AwesomeSockets?

Cloud you please give me some example just like:

  1. How can server process multiple requests which send by a 'keep-live' connection.
    I have created a client application(.net Framework, Win Form)
    Connected at first, and then send some messages, but server didn't receive any.
  2. Dose 'AwesomeSocket' support concurrent?

TCP connections data exchange cpu memory leak

When I am sending and receiving a lot of bytes, there is a problem with cpu memory,
CPU memory is fully stuffed, a usage of CPU memory is rising high. What should I do to escape it?

here is the server:

ServerSocket = AweSock.TcpListen(14804);
ClientSocket = AweSock.TcpAccept(ServerSocket);
started = true;
byte[] file = File.ReadAllBytes(@"C:\Users\link\Desktop\Screenshot_1.png");
while (started)
{
    Buffer outBuf = Buffer.New(file.Length);
    Buffer.ClearBuffer(outBuf);
    Buffer.Add(outBuf, file);
    Buffer.FinalizeBuffer(outBuf);
    int bytesSent = AweSock.SendMessage(ServerSocket, outBuf);
    Console.WriteLine("Sent");
}

here is the client:

Client = AweSock.TcpConnect("127.0.0.1", 14804);
byte[] file = File.ReadAllBytes(@"C:\Users\link\Desktop\Screenshot_1.png");
while (started)
{
    Buffer inBuf = Buffer.New(file.Length);
    Tuple<int, EndPoint> received = AweSock.ReceiveMessage(Client, inBuf);
    Console.WriteLine("Received");
    frames++;
}

endless loop may increase the cpu memory usage, but I need it

Different string encoding between server and client

Hi, I tried to send a string data to a server using AwesomeSockets from a non-AwesomeSockets client (due to Xamarin.Android, code partially copied from Microsoft Docs here).

I actually uses a simple Bit Scrambling algorithm available in Here to scramble the data, still in ASCII though. The server successfully received the string. However, It receives a different string like it was made of Chinese chars.

This is the code I use in client:

string toBeSend = $"{UserName.Text}\0{PointCount.Text}"; // -> "MyName\01280"
string encodedSend = PSWBit6Codec.Encode(toBeSend); // -> "SWeNXVueBc`p"
byte[] byteData = Encoding.ASCII.GetBytes(encodedSend); 
sendSocket.BeginSend(byteData, 0, byteData.Length, 0, new AsyncCallback(SendCallback), client); 
                          // -> Send "SWeNXVueBc`p" as byte array

The code I use in server:

Buffer recv = Buffer.New();
Buffer.ClearBuffer(recv);
Tuple<int, EndPoint> recvTuple = receiverSocket.ReceiveMessage(recv);
string recvStr = Buffer.Get<string>(recv); // -> It receives "啐坍䍀牄卌恌"
string recvstrREnc = Encoding.ASCII.GetString(Encoding.UTF8.GetBytes(recvStr)); // -> Produces "???????????"

What did I miss here? is the Buffer class using a specific encoding when trying to get a string?

How do I read response?

I have setup example from the main page with a different address (a whois server on port 43) and it runs ok with no exception but I cannot see any of the response data.

This line:

Tuple<int, EndPoint> received = AweSock.ReceiveMessage(server, inBuf);

I look in received inside debugger and cant see any value or byte array to read. Sorry for basic question but I can't figure it out from example. How do I read response?

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.