Giter Club home page Giter Club logo

Comments (4)

entroPyth avatar entroPyth commented on July 29, 2024 3

I experienced the same problem and found the issue was with the Virtualbox net adapter taking priority for multicast. It works if you add the registry keys for Unicast, but found the audio is too choppy to be usable over WiFi from laptop to desktop plugged into gigabit ethernet. Confirmed the virtual sound card works on Windows 10 Build 1809 too.

from scream.

dzcpy avatar dzcpy commented on July 29, 2024

Have you solved the issue?

from scream.

ktb92677 avatar ktb92677 commented on July 29, 2024

Hey guys. The example @duncanthrax has for the windows c# UDP client does not work at all. I ended up hand programming a UDP client with Visual C++ and I managed to get it to work. Here's the code (please bare in mind that this code is NOT cleaned up at all and should only be used for demo purposes):

UDP_Client.h

#ifndef UDP_CLIENT_H_
#define UDP_CLIENT_H_

#define _WINSOCK_DEPRECATED_NO_WARNINGS

#include<stdio.h>
#include<winsock2.h>

#include <iostream>

using namespace std;

#pragma comment(lib,"ws2_32.lib") //Winsock Library

#define SERVER "127.0.0.1"	//ip address of udp server
#define BUFLEN 1500	//Max length of buffer
#define PORT 4011	//The port on which to listen for incoming data

struct UDP_CLIENT {
	struct sockaddr_in si_other;
	int s, slen = sizeof(si_other);
	char buf[BUFLEN];
	char message[BUFLEN];
	WSADATA wsa;
};

void Initialize_UDP_CLIENT(UDP_CLIENT*);
int Receive_UDP_CLIENT(UDP_CLIENT*, char*, int);
void Close_UDP_CLIENT(UDP_CLIENT*);

#endif

UDP_Client.cpp

#include "UDP_Client.h"

void Initialize_UDP_CLIENT(UDP_CLIENT* client) {

	//Initialise winsock
	printf("\nInitialising Winsock...");
	if (WSAStartup(MAKEWORD(2, 2), &client->wsa) != 0)
	{
		printf("Failed. Error Code : %d", WSAGetLastError());
		exit(EXIT_FAILURE);
	}
	printf("Initialised.\n");

	//create socket
	if ((client->s = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) == SOCKET_ERROR) {
		printf("socket() failed with error code : %d", WSAGetLastError());
		exit(EXIT_FAILURE);
	}

	int opt = 1;

	if (setsockopt(client->s, SOL_SOCKET, SO_REUSEADDR, (const char *)&opt, sizeof(opt)) < 0) {
		printf("setsockopt() failed with error code : %d", WSAGetLastError());
		exit(EXIT_FAILURE);
	}

	u_long nMode = 1; // 0: BLOCKING
	if (ioctlsocket(client->s, FIONBIO, &nMode) == SOCKET_ERROR) {
		printf("ioctlsocket() failed with error code : %d", WSAGetLastError());
		exit(EXIT_FAILURE);
	}

	//setup address structure
	memset((char *)&client->si_other, 0, sizeof(client->si_other));
	client->si_other.sin_family = AF_INET;
	client->si_other.sin_port = htons(PORT);
	client->si_other.sin_addr.s_addr = inet_addr(SERVER);

	int bind_status = bind(client->s, (SOCKADDR *)&client->si_other, sizeof(client->si_other));

	cout << bind_status << " " << WSAGetLastError() << endl;
}


int Receive_UDP_CLIENT(UDP_CLIENT* client, char* buffer, int size) {

	return recvfrom(client->s, buffer, size, 0, (struct sockaddr *) &client->si_other, &client->slen);

	/*
	if (received_size == SOCKET_ERROR)
	{
		printf("recvfrom() failed with error code : %d", WSAGetLastError());
		exit(EXIT_FAILURE);
	}
	*/
	//return received_size;
}

void Close_UDP_CLIENT(UDP_CLIENT* client) {
	closesocket(client->s);
	WSACleanup();
}

from scream.

ktb92677 avatar ktb92677 commented on July 29, 2024

Just call Receive_UDP_CLIENT in a loop. If you have any trouble assembling the PCM let me know!

from scream.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.