1

UDP is a connection-less protocol. In my server, I am using two sockets in listening mode:

sfd3000=CreateUDPSocketAndListen(3000);
sfd14000=CreateUDPSocketAndListen(4000); 

I am using

socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);

to create the sockets.

I am receiving the request using one socket

 recvfrom(sfd3000, reqbuff,1024, 0,(struct sockaddr *)&clientinfo, (socklen_t *)&sinfolen);

Can I use the other listening socket to send the response, using the same clientinfo structure

sendto(sfd4000,respbuff,resplen, 0,(struct sockaddr *) &clientinfo, sinfolen);

Is this possible in UDP as it's a connection-less protocol?

4

1 回答 1

1

您不需要监听 UDP 协议。如果想读取一些数据,您可以打开并阻止读取/您可以在打开后写入数据。

In short you can send response through another port

于 2013-05-28T12:51:58.470 回答