Trevinlc1997
Posts: 13
Joined: Mon Nov 28, 2016 11:44 pm

TCP Server - I allowed through firewall but still nothing

Tue Nov 29, 2016 10:41 pm

Alright so I wrote some really quick sample code to try and get a TCP server online on my Raspberry Pi 3, I did some research and found I had to allow it through the firewall, I did that. it said "OK" but still it didn't work. (I copied and pasted the code on my win32 application and the server starts up just fine).

By the way this is one of my first UWP applications, but I know setting it in this function works because I had my Raspberry Pi connect to a TCP server (the one I copied and pasted to my win32 application) and it sent data fine and everything.

Used this command to allow through firewall:

Code: Select all

netsh advfirewall firewall add rule name="Open Port dddd" dir=in action=allow protocol=TCP localport=dddd

Code: Select all

Output: OK
Here is my sample code:

Code: Select all

void StartupTask::Run(IBackgroundTaskInstance^ taskInstance)
{ 

	WSADATA WsaData = { 0 };
	WSAStartup(MAKEWORD(2, 2), &WsaData);

	ADDRINFOW hints = { 0 }, *results = nullptr;
	hints.ai_family = AF_INET;
	hints.ai_protocol = IPPROTO_TCP;
	hints.ai_socktype = SOCK_STREAM;
	hints.ai_flags = AI_PASSIVE;

	GetAddrInfoW(L"192.168.1.143", L"9000", &hints, &results);
	SOCKET hSocket = socket(results->ai_family, results->ai_socktype, results->ai_protocol);
	bind(hSocket, results->ai_addr, static_cast<int>(results->ai_addrlen));
	listen(hSocket, 0);

	char RecvBuffer[500];
	SOCKET hConnection = INVALID_SOCKET;
	hConnection = accept(hSocket, nullptr, nullptr);
	while (true)
	{
		send(hConnection, "Hello!", 7, 0);
	}
}

karlssja
Posts: 3
Joined: Mon Oct 17, 2016 4:57 pm

Re: TCP Server - I allowed through firewall but still nothin

Wed Nov 30, 2016 7:37 am

If you are using port 9000 the command should be

Code: Select all

netsh advfirewall firewall add rule name="Open Port 9000" dir=in action=allow protocol=TCP localport=9000

Trevinlc1997
Posts: 13
Joined: Mon Nov 28, 2016 11:44 pm

Re: TCP Server - I allowed through firewall but still nothin

Wed Nov 30, 2016 10:29 pm

karlssja wrote:If you are using port 9000 the command should be

Code: Select all

netsh advfirewall firewall add rule name="Open Port 9000" dir=in action=allow protocol=TCP localport=9000
My bad I forgot to update the command but I did use the one you have specified and it still does not work sadly.

dobova86
Posts: 71
Joined: Wed Dec 05, 2012 5:32 pm

Re: TCP Server - I allowed through firewall but still nothin

Mon Dec 12, 2016 9:41 pm

I think you need to declare low level functionality use in the app package configuration. Sorry I can't remind the xml file name at the moment.

Return to “Windows 10 for IoT”