Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8631185
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T09:11:01+00:00 2026-06-12T09:11:01+00:00

For a programming project in school we have to design a basic client/server setup

  • 0

For a programming project in school we have to design a basic client/server setup using tcp protocol and then udp protocol. I already got the TCP working using read() and write() from the C Socket library. I now need to create a “reliable UDP” system. For instance:

“When the server receives the length message it will wait up to 500 milliseconds for that number of bytes to be sent. If it receives the correct number of bytes, it will respond with a string containing the characters “ACK” (a common abbreviation for an acknowledgement). If it does not receive the correct number of bytes by the end of the timeout period, the server will give up and silently exit.”

I have the sendto() and recvfrom() functions set up, but I am not sure how to do the timeout feature so that it only waits 500ms for the second msg to be sent. I also have to do it later on the client side if it doesn’t receive the “ACK” and resend the length msg + msg a few times. How can do I do the timeout?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T09:11:02+00:00Added an answer on June 12, 2026 at 9:11 am

    Add the following function in your program and use it instead of using the recvfrom function directly.

    the following functiong has the same input parameter of recvfrom function + a timeout input parameter in the last

    #include <sys/types.h>
    #include <sys/socket.h>
    #include <netinet/in.h>
    #include <arpa/inet.h>
    #include <netdb.h>
    #include <unistd.h>
    
    int timeout_recvfrom (int sock, char *buf, int *length, struct sockaddr_in *connection, int timeoutinseconds)
    {
        fd_set socks;
        struct timeval t;
        FD_ZERO(&socks);
        FD_SET(sock, &socks);
        t.tv_sec = timeoutinseconds;
        if (select(sock + 1, &socks, NULL, NULL, &t) &&
            recvfrom(sock, buf, *length, 0, (struct sockaddr *)connection, length)!=-1)
            {
            return 1;
            }
        else
            return 0;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For a school project i need to write or use a online programming editor.
I do have experience with Ruby on Rails, and am programming a project in
I was programming some stuff in a Xcode project, then I decided to move
I'm nearing the end of a school project with programming in Xcode, but right
I've created this little quiz for a school project using Java and MySQL. Now
I'm writing a TCP chat server ( programming language does not mather ). It's
I'm in the midst of creating my school project for our programming class. I'm
I'm the network programmer on a school game project. We want to have up
For a programming project, I need to read pixels from a loaded image using
I have a college programming project in C++ divided into two parts. I beggining

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.