I wrote a simple udp server that needs to transfer some data to several of its clients. but although the server successfully sends, it cannot transmit at least one byte. The return value of send is 0, although I have enough data to transmit. Here you can see the code for the specified server: http://pastebin.com/zeMcwd6X
Can you help people find a possible culprit for this? Any answer in this regard would be appreciated. Many thanks in advance! Mawia
Edit: Guys, as Mr. Yasser rightly pointed out, this typo has been fixed. But the fact is that the problem persists even after fixing this.
Your problem is here:
int n = 0; for( k = 0; k < numberOfConnections; k++ ) n = sendto( sockfd, data, n, 0, ... );
Pay attention to the purpose - you are asking the socket to send an empty datagram. n=0;
n=0;
Some other notes on your code:
Hope this helps.
- , - . . , mbone.
epoll(2)/kqueue(2) . : http://www.kegel.com/c10k.html http://pl.atyp.us/content/tech/servers.html
epoll(2)
kqueue(2)
sendto. , , :
sendto
n=sendto(sockfd,data,n,0,(struct sockaddr *)&setOfClient[k],(char*)(setOfClient+1)-(char*)setOfClient);
n 0 - int n=0;. , 0 , n .
n
0
int n=0;
, strlen(data) n sendto , sendto, .
strlen(data)
. S. , , , , , man 2 sendto.
man 2 sendto
Source: https://habr.com/ru/post/1745438/More articles:How to connect to an outdated Informix database? - informixПочему функция PHP без параметров требует скобок? - functionProblem with Informix JDBC, MONEY and decimal separator in string literals - javaTwitter API with urllib2 in python - pythonWhat are the N-level structure levels and their functions for WEB development in PHP? - oophttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1745439/how-to-enforce-users-to-create-objects-of-class-derived-from-mine-with-new-only&usg=ALkJrhireCyiXyQzQCQdqFZYdOUWP_7GFwFast ruby http library for large XML downloads - httpjqgrid delGridRow not working - jqueryHow to set local buffer variable from Eval: to .dir-local.el? - emacsC # How to create objects without defining classes? - c #All Articles