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

  • Home
  • SEARCH
  • 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 3392962
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T03:59:40+00:00 2026-05-18T03:59:40+00:00

This sends data only once which seems irrational to me as it is in

  • 0

This sends data only once which seems irrational to me as it is in a for loop:

char* hello;
for (int i = 0; i < 10; i++) {

    hello = "Hello world!\n";
    if (UDT::ERROR == UDT::send(client, hello, strlen(hello) + 1, 0))
    {
        cout << "send: " << UDT::getlasterror().getErrorMessage();
    }

}

Shouldn’t it send data 10 times? I don’t understand it. Here is the whole program (it’s quite short):

int main()
{
    UDTSOCKET client;
    sockaddr_in serv_addr;
    serv_addr.sin_family = AF_INET;
    serv_addr.sin_port = htons(9000);
    inet_pton(AF_INET, "127.0.0.1", &serv_addr.sin_addr);
    memset(&(serv_addr.sin_zero), '\0', 8);

    client = UDT::socket(AF_INET, SOCK_STREAM, 0);

    // connect to the server, implict bind
    if (UDT::ERROR == UDT::connect(client, (sockaddr*)&serv_addr, sizeof(serv_addr)))
    {
        cout << "connect: " << UDT::getlasterror().getErrorMessage();
    }

    char* hello;
    for (int i = 0; i < 10; i++) {

        hello = "Hello world!\n";

        if (UDT::ERROR == UDT::send(client, hello, strlen(hello) + 1, 0))
        {
            cout << "send: " << UDT::getlasterror().getErrorMessage();
        }

    }

    UDT::close(client);

    system("pause");
}
  • 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-05-18T03:59:41+00:00Added an answer on May 18, 2026 at 3:59 am

    Have you checked the server side code. Client is doing sends in a for loop, how is the server side receiving them?

    Edit:
    In reference to your post here. If your server code looks like this, it will receive only once. The server is getting the connection from the client then receives once then again waits for connection from a client. But the client keeps sending in a loop. Its just a guess that this is your server code, I could be wrong.

    while (true)
    {
      UDTSOCKET recver = UDT::accept(serv, (sockaddr*)&their_addr, &namelen);
    
      cout << "new connection: " << inet_ntoa(their_addr.sin_addr) << ":" << ntohs(their_addr.sin_port) << endl;
    
      if (UDT::ERROR == UDT::recv(recver, data, 100, 0))
      {
        cout << "recv:" << UDT::getlasterror().getErrorMessage() << endl;
        //return 0;
      }
    ....................
    ....................
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

OK, I am quite new to this Objective-C and JSON thing, so please bare
When someone sends me an email by the contact form in magento, the emails
I have an working Excel file, with file I can send data extracted from
I have a windows service, that is occasionally crashing and stopping when an unhandled
Essentially, I'd like a special form of an Interface for Exceptions that requires anyone
I've been doing alot of searching around the website but not even sure if
How does the iOS platform handle memory-mapped files during low-memory scenarios? By low-memory scenarios,
My experience with the SSL/TLS protocol and then OpenSSL library is very limited. Essentially
I have started to write a Python 3.x client application. The server application exists
I've got a ListView with a 'show next results' button. The list is filled

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.