有哪些TCP通信的應用層的開源項目值得學習?

自己設計應用層協議,使用TCP連接來做通信,在Linux使用c++來實現,類似這樣的有哪些開源項目值得學習。主要想學習如何基於事件來處理消息的封包和解包,以及業務邏輯。


有幾個特別好 TCP RPC Service

1. ☆☆ ZeroC Ice

Welcome to ZeroC, the Home of Ice

The Internet Communications Engine (Ice) is a modern distributed computing platform with support for C++, .NET, Java, Python, Objective-C, Ruby, PHP, and ActionScript. Ice is used in mission-critical projects by companies all over the world.

Ice is easy to learn, yet provides a powerful network infrastructure and vast array of features for demanding technical applications.

Ice is free software, available with full source, and released under the terms of GNU General Public License (GPL). Commercial licenses are available for customers who wish to use Ice for closed-source software.

2. Facebook Thrift

Apache Thrift

Thrift: The Missing Guide

The Apache Thrift software framework, for scalable cross-language services development, combines a software stack with a code generation engine to build services that work efficiently and seamlessly between C++, Java, Python, PHP, Ruby, Erlang, Perl, Haskell, C#, Cocoa, JavaScript, Node.js, Smalltalk, OCaml and Delphi and other languages.

3. gRPC Google Protocol Buffers

grpc · GitHub

Building on the HTTP/2 standard brings many capabilities such as bidirectional streaming, flow control, header compression, multiplexing requests over a single TCP connection and more.

gRPC VS thrift

The major differences are pretty simple:

  1. This solves things with protobufs, Google"s serialization library. protobufs has implementations in many more languages, its implementation is older, and it"s a bit more compact than the default Thrift serialization format. It"s also less expressive (e.g., protobufs can"t distinguish between an empty collection and null, whereas Thrift can).
  2. Thrift has a custom RPC format; gRPC just uses HTTP/2 with some slightly formalized REST generation from a given RPC interface. You honestly could accidentally be gRPC-compliant right now with a vanilla protobufs-over-HTTP/2 implementation.

4. ☆☆ Apache Avro

Welcome to Apache Avro!

Avro is a remote procedure call and data serialization framework developed within Apache"s Hadoop project. It uses JSON for defining data types and protocols, and serializes data in a compact binary format. Its primary use is in Apache Hadoop, where it can provide both a serialization format for persistent data, and a wire format for communication between Hadoop nodes, and from client programs to the Hadoop services.It is similar to Thrift, but does not require running a code-generation program when a schema changes (unless desired for statically-typed languages).

5. libuv

libuv/libuv · GitHub

based on libevent

  • Full-featured event loop backed by epoll, kqueue, IOCP, event ports.

  • Asynchronous TCP and UDP sockets

  • Asynchronous DNS resolution

  • Asynchronous file and file system operations

  • File system events

  • ANSI escape code controlled TTY

  • IPC with socket sharing, using Unix domain sockets or named pipes (Windows)

  • Child processes

  • Thread pool

  • Signal handling

  • High resolution clock

  • Threading and synchronization primitives

    歡迎補充~


  • ?MQ (https://github.com/zeromq)


    引用一下 awesome-cpp : fffaraz/awesome-cpp · GitHub ( 大部分是 TCP )

    Inter-process communication

    • Apache Thrift - Efficient
      cross-language IPC/RPC, works between C++, Java, Python, PHP, C#, and
      many more other languages. Originally developed by Twitter. [Apache2]
    • Cap"n Proto - Fast data interchange format and capability-based RPC system. [MIT]
    • gRPC - A high performance, open source, general-purpose RPC framework. [BSD] website
    • libjson-rpc-cpp - JSON-RPC framework for C++ servers and clients. [MIT]
    • nanomsg - A simple high-performance implementation of several "scalability protocols". [MIT] website
    • simple-rpc-cpp - A simple RPC wrapper generator to C/C++ functions. [BSD]
    • xmlrpc-c - A lightweight RPC library based on XML and HTTP. [BSD]
    • ZeroMQ - High-speed, modular asynchronous communication library. [LGPL]


    GitHub - whtc123/libuvc: Coroutines and asychronous I/O for cross-platform

    libmill

    複雜的邏輯不建議用非同步IO框架,代碼維護非常困難


    不請自來,LWIP最好用,還有LWIPWIN32版


    剛起步可以看下Libevent,用C寫的


    muduo


    MINA、Grizzly


    推薦閱讀:

    關於 python gevent 架框 作為 TCP伺服器 的 代碼問題 , 每個 socket 的 消息 接收 是否有使用 事件監聽回調的方法呢?
    如何學習 TCP/IP 協議?
    在TCP的四次分手當中,被動關閉方是如何知道數據已經接收完了?
    DNS解析的過程是什麼,求詳細的?
    《tcp/ip詳解》三卷本該怎麼看?

    TAG:Linux | 開源項目 | C | Socket | TCPIP |