I try to send udp packet between on my WSL2 localhost client and server, i can sent data successfully but when want to analyze on wireshark, wireshark cannot capture anything at loopback traffic adapter and vEthernet capture. Running program and wireshark windows image at after the sender code.
sender.cpp
#define PORT 50254
int main(){
Client* client = new Client("127.0.0.1", PORT);
memset(&client->serv_addr, 0, sizeof(client->serv_addr));
client->serv_addr.sin_family = AF_INET;
client->serv_addr.sin_port = htons(port);
client->serv_addr.sin_addr.s_addr = inet_addr(client->ipAddres);
if ((client->Socket = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
perror("socket creation failed");
exit(EXIT_FAILURE);
}
if (connect(client->Socket, (struct sockaddr*)&client->serv_addr, sizeof(client->serv_addr)) < 0)
{
printf("\n Error : Connect Failed \n");
exit(0);
}
char* message = "Hello Server";
cout << "Sent Size : " << send(client->Socket,message, 100, 0) << endl;
}