Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4108298
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T21:38:09+00:00 2026-05-20T21:38:09+00:00

I saw something that was a red flag for me when I ran this:

  • 0

I saw something that was a red flag for me when I ran this:

nc -l -u -p 1500

This netcat command makes it listen for packets from UDP port 1500. Once i ran this on the windows command line, I immediately got a Windows Firewall has disabled features blah blah blah popup message. Sadly I realized that my own UDP code did not trigger this, so I must be doing something wrong. Here is the current iteration of my winsock code in case it is relevant:

#ifdef WIN32
#include <winsock2.h>
#else
#include <sys/socket.h>
#include <netdb.h>
#include <arpa/inet.h>
#endif
#include <sys/types.h>
#include <stdio.h>
#include <sys/time.h>
#include <string.h>
#include <TinyThread++/tinythread.h>
#include <iostream>

#ifdef WIN32
class WSA {
public:
    WSA() {
        WSADATA wsaData;
        WORD wVersionRequested = MAKEWORD(2,0);
        int err = WSAStartup(wVersionRequested, &wsaData);
        if (err != 0) {
            PRINT("WSAStartup failed with an error: "); PRINT_INT(err);
            exit(-1);
        }
    }
    ~WSA() {
        WSACleanup();
    }
};
static WSA wsa_placeholder;
static int UDPSocket = -1;
static int listen_port = -1;

int initUDPSocket(int port) {
    listen_port = port;
    UDPSocket = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP);
    ASSERT(UDPSocket != -1);
    sockaddr_in myaddr; 
    memset(&myaddr,0,sizeof(myaddr)); // clear it
    myaddr.sin_family = AF_INET;
    myaddr.sin_addr.s_addr = inet_addr("127.0.0.1");
    ASSERT(listen_port > 0);
    myaddr.sin_port = htons(listen_port);
    ASSERT(bind(UDPSocket, (sockaddr *)&myaddr, sizeof(myaddr))!=-1);
    return UDPSocket;
}


void closeUDPSocket() {
    closesocket(UDPSocket);
    UDPSocket = -1;
}

using namespace std;
using namespace tthread;
void UDPListenThread (void *arg) {
    cout << "UDP Listening thread ID: " << this_thread::get_id() << endl;
    while (1) {
        sockaddr_in from;
        int fromlen = sizeof(from);
        size_t len;
        char buf[2048];
        len = recvfrom(UDPSocket, buf, 2048, 0, (sockaddr*)&from, &fromlen);
        printf("Received packet from %s:%d, length %u\n",inet_ntoa(from.sin_addr),
                ntohs(from.sin_port),len);
        hexdump(buf,len);
        if (len == 2 && buf[0] == 'q' && buf[1] == 0x0a) {
            break;
        }
    }
    cout << "Received a quit packet. exiting routine (thread)." << endl;
}
thread startUDPListenThread() {
    cout << "Main thread ID: " << this_thread::get_id() << endl;
    return thread(UDPListenThread,0);
}

If I use netcat to send UDP packets from the same machine to my program, it receives them. But it does not receive packets from the internet.
Also, why is it that Windows Firewall didn’t seem to mind? Is there something else that I need to do similar to WSAStartup?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T21:38:10+00:00Added an answer on May 20, 2026 at 9:38 pm

    You are binding to localhost, Windows firewall has separate configurations for Private, Public, and Domain, which presumably map onto intranet & localhost, the Internet, and Kerberos authenticated domain.

    Bind to 0.0.0.0 (INADDR_ANY) to listen on all interfaces.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I saw this same question for VIM and it has been something that I
I need to write a Red Hat Linux command line tool that launches a
I ran across some very interesting code that makes me wonder about what bool
I thought I read/saw/heard something saying that apps built for iPhone 4's Retina Display
I saw something about needing to have the assembly available for the type of
I saw this in an answer to another question , in reference to shortcomings
I saw this quote on the question: What is a good functional language on
I saw this question asked about C# I would like an answer for PHP.
I saw this quote in this question : MS support is poor, except when
I saw that __VIEWSTATE field gets rendered even though I have set the EnableViewState=false

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.