TCP/IP Networking with Boost.Asio

แชร์
ฝัง
  • เผยแพร่เมื่อ 25 ส.ค. 2024

ความคิดเห็น • 14

  • @UtahCppProgrammers
    @UtahCppProgrammers  ปีที่แล้ว +3

    To stop an io_context from running out of work, use the executor_work_guard; this is what I was trying to remember at the end of the video :). See the documentation here:
    www.boost.org/doc/libs/1_81_0/doc/html/boost_asio/reference/io_context.html#boost_asio.reference.io_context.stopping_the_io_context_from_running_out_of_work

  • @bzdzgwa
    @bzdzgwa ปีที่แล้ว

    One thing you haven't mentioned. If the program waits for a data to send to the server (from a user for example) and there are no asynchronous read/write operations pending, you recommended using executor_work_guard, to keep io_context.run() method busy. But what if the server closes the connection at that moment. How the program will know about this?

    • @UtahCppProgrammers
      @UtahCppProgrammers  ปีที่แล้ว

      If you are attempting to send/receive data to/from a server and it closes the connection, your handler is invoked with an error code indicating the connection was closed. TCP/IP has a specific sequence that the socket goes through in the protocol in order to indicate that one side has closed the connection cleanly. If the other end of a socket just crashes, then you get an error code when you attempt to read or write on that connection, possibly after a timeout period (e.g. you are waiting for acknowledgement of sent data and it doesn't arrive before the timeout).

    • @bzdzgwa
      @bzdzgwa ปีที่แล้ว

      If I wanted to be notified immediately if the server closed the connection gracefully, should I always have async_read in the background? Will the async_read handler be invoked immediately with an error in such case?

    • @UtahCppProgrammers
      @UtahCppProgrammers  ปีที่แล้ว

      @@bzdzgwa In TCP/IP, when one side closes the connection a FIN packet is sent. So if the server closes the connection, you would get this notification as an error code the next time you attempt to do anything with the connection. That's how I understand it. My advice is to write a simple program and test it out to find out what the exact behavior will be. You can use the sample code I wrote in the linked github repository to try this.

  • @user-cz2fd4ik7z
    @user-cz2fd4ik7z 6 หลายเดือนก่อน

    An IPv6 address is 128 bits not 64. You stated it was 4 x 16 bits. You may be thinking of the host portion of the address, but you'd need to know the full address to communicate.

  • @vadiks20032
    @vadiks20032 ปีที่แล้ว

    how did you make CMD divide itself by 4 in the single window? is it CMD feature or just some code to make it look like that

    • @UtahCppProgrammers
      @UtahCppProgrammers  ปีที่แล้ว +1

      I'm using the curses library to create text windows. On Windows, the implementation of the curses library is provided by pdcurses; on Linux the implementation comes from ncurses, which is usually installed on the system and not through vcpkg.
      You can read about the curses API here: invisible-island.net/ncurses/man/ncurses.3x.html

  • @user-il5ws2tw5b
    @user-il5ws2tw5b ปีที่แล้ว

    Can you help me with source of knowledges about boost::asio. Now I do my course work. And the main task is to create client-server application to send messages between clients.
    So, where I can read more about this topic.
    I ask this question because there are a lot of sources, but information there is not clear.

    • @alang.2054
      @alang.2054 11 วันที่ผ่านมา

      😂

  • @UtahCppProgrammers
    @UtahCppProgrammers  ปีที่แล้ว

    Example source code: github.com/LegalizeAdulthood/asio-tcp-ip

  • @LavinOficial
    @LavinOficial ปีที่แล้ว

    Could you make a boost asio video that handles the json protocol for a communication with python flask please

    • @alang.2054
      @alang.2054 11 วันที่ผ่านมา

      Don't use python! 😂