Hello guys
I want to send some text messages from server to many clients. client only show them on a messagebox. since there are many client, I get a udp socket, send data to it, and then closesocket. my problem is: after writing data to socket, If I immediately close the socket, message will be lost. where I should close the socket?
thanks in advance
mr.abzadeh
Edit: the original question was not clear, so I edited it
Edit: my code is added here(simplified)
SOCKET socket1 = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
ADDRINFOW * pAddr;
ADDRINFOW hints;
memset(&hints, 0, sizeof(hints));
hints.ai_family = AF_INET;
hints.ai_protocol = IPPROTO_UDP;
hints.ai_socktype = SOCK_DGRAM;
GetAddrInfoW( wszHostName, lpPortName, &hints, &pAddr);
sendto( socket1, (const char *)pBuf, uSendLen, 0, pAddr->ai_addr, Addr->ai_addrlen);
closesocket(socket1);