Hi I am implementing P2P chatting application where server will mediator for exchangeing IP and port to connecting peer. I am getting WSAEAFNOSUPPORT 10047 error .
I have created UDP socket
sockfd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP ); then iam binding it to local ip and port.
if (bind(sockfd,(struct sockaddr *)&localaddr,sizeof(localaddr))<0) { Error_Code("create_socket:bind()"); return -1; }
then I am contacting the server.
// connecting with server
sendto(sockfd,pBuffer,sizeof (nMessageType),0,(const sockaddr *)&config.serverAddr,size);
server keeps track of the other connected peer.once peer connects to the server it return ip and port of other peer.so a peer can use IP and port to directly connect to other peer. but i am getting error while sending data to to other peer
// sending data to peer
int ret = sendto(sockfd,sendBuf, sizeof(nMessagetype),0,(const sockaddr *)&m_peer.publicaddr,sockAddLen); it return 10047 WSAEAFNOSUPPORT error.
Here I am using same socket to contact server and other peer is this reason for this? I don't understand what is going wrong here. It is able to connect with server properly but it is failing to connect other peer.