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");
}
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.