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 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

Using Java sockets, I made a simple server. This works because it sends data
I have a form which has a single textbox that sends some data to
I'm trying to get some data from a PHP file which only gives a
I send data in this way: <form method=post enctype=text/plain action=Func> And I have a
I am trying to send data from an activity to service via intents. This
I need to send some data with radio button. This buttons are <td> <span
I want to send the post data from an input like this: <input type=file
The data returned when i send a request with NSURLconnection contains script like this
<action android:name=android.intent.action.SEND /> <category android:name=android.intent.category.DEFAULT /> <data android:mimeType=text/plain /> this is in my manifest
I currently have a web form aspx page that calls RegisterClientScriptBlock. This sends down

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.