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

  • SEARCH
  • Home
  • 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 8540351
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T11:34:40+00:00 2026-06-11T11:34:40+00:00

I am making a Winamp plugin with the single function of sending the details

  • 0

I am making a Winamp plugin with the single function of sending the details of the song being played over HTTP to a webpage/webserver. I couldn’t find anything like this that actually works, so decided to dive in for the first time into C++ and just do it myself.

The plugin is a C++ DLL file. I have got to the point where I can output the song title to a windows message box every time a new song is played (not bad for a C++ first-timer! 😉 )

Where am I stuck:

I couldn’t find anything to get me in the push notification on C++ direction AT ALL.

I tried, without any success, embedding/including HTTP libraries into my DLL to try post requests instead. libcurl, this library here, and this library too – but couldn’t get any of them to work! I just kept getting linking errors and then some. After a few hours I just gave up.

I am a very skilled JavaScript programmer so I thought perhaps using JS to connect into a push notification service can work out but running JS inside C++ looks too complicated to me. Perhaps I’m wrong?

Bottom line, I don’t know which solution is better (read: easier) to implement – push notifications or post requests?

I appreciate any solutions/input/directions/information or whatever you got. I can post code but the only code I have is the part getting the song information from Winamp and that part works.

Thanks in advance.

EDIT: I guess it’s worth noting I’m using the new VS2012?

  • 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-06-11T11:34:41+00:00Added an answer on June 11, 2026 at 11:34 am

    That’s OK to use these kind of libraries, but when speaking of C++, I mainly think of “pure code”, so I like the native style to do something, and do it without the help of libraries.

    Thinking of that, I can provide you an example on how to send a HTTP’s POST request, using Microsoft’s winsock2 library.

    First, I’d like to point out that I used this link to have a base on how to use winsock2.h.

    Ok, now going on to the code, you need these includes:

    #include <string>
    #include <sstream>
    #include <winsock2.h>
    

    You’ll also need to link winsock2 library (or specify it in your project settings, as you use VS2012):

    #pragma comment(lib, "ws2_32.lib")
    

    Now, the function I edited from the link (I’ve just edited it to make it look simpler, and also to do some error check and proper cleanup):

    int http_post(char *hostname, char *api, char *parameters, std::string& message)
    {
        int result;
    
        WSADATA wsaData;
        result = WSAStartup(MAKEWORD(1, 1), &wsaData);
    
        if(result != NO_ERROR)
        {
            //printf("WSAStartup failed: %d\n", result);
            return 0;
        }
    
        sockaddr_in sin;
    
        int sock = socket(AF_INET, SOCK_STREAM, 0);
        if(sock == INVALID_SOCKET)
        {
            //printf("Error at socket(): %ld\n", WSAGetLastError());
            WSACleanup();
            return 0;
        }
    
        sin.sin_family = AF_INET;
        sin.sin_port = htons(80);
    
        struct hostent *host_addr = gethostbyname(hostname);
        if(host_addr == NULL)
        {
            //printf("Unable to locate host\n");
            closesocket(sock);
            WSACleanup();
            return 0;
        }
    
        sin.sin_addr.s_addr = *((int *)*host_addr->h_addr_list);
    
        if(connect(sock, (const struct sockaddr *)&sin, sizeof(sockaddr_in)) == SOCKET_ERROR)
        {
            //printf("Unable to connect to server: %ld\n", WSAGetLastError());
            closesocket(sock);
            WSACleanup();
            return 0;
        }
    
        std::stringstream stream;
        stream << "POST " << api << " HTTP/1.0\r\n"
               << "User-Agent: Mozilla/5.0\r\n"
               << "Host: " << hostname << "\r\n"
               << "Content-Type: application/x-www-form-urlencoded;charset=utf-8\r\n"
               << "Content-Length: " << strlen(parameters) << "\r\n"
               << "Accept-Language: en-US;q=0.5\r\n"
               << "Accept-Encoding: gzip, deflate\r\n"
               << "Accept: */*\r\n"
               << "\r\n" << parameters
        ;
    
        if(send(sock, stream.str().c_str(), stream.str().length(), 0) == SOCKET_ERROR)
        {
            //printf("send failed: %d\n", WSAGetLastError());
            closesocket(sock);
            WSACleanup();
            return 0;
        }
    
        if(shutdown(sock, SD_SEND) == SOCKET_ERROR)
        {
            //printf("shutdown failed: %d\n", WSAGetLastError());
            closesocket(sock);
            WSACleanup();
            return 0;
        }
    
        char buffer[1];
    
        do
        {
            result = recv(sock, buffer, 1, 0);
            if(result > 0)
            {
                //printf("Bytes received: %d\n", result);
                message += buffer[0];
            }
            else if(result == 0)
            {
                //printf("Connection closed\n");
            }
            else
            {
                //printf("recv failed: %d\n", WSAGetLastError());
            }
        }
        while(result > 0);
    
        closesocket(sock);
        WSACleanup();
    
        return 1;
    }
    

    As you are using a DLL, I commented out the printfs, so you can use your proper output function according to the Winamp plugin API.

    Now, to use the function, it’s self-explanatory:

    std::string post;
    http_post("www.htmlcodetutorial.com", "/cgi-bin/mycgi.pl", "user=example123&artist=The Beatles&music=Eleanor Rigby", post);
    

    By doing this, and checking the function return number (either 1 for success or 0 for failure), you can parse the result string returned from the site, and check if everything went OK.

    About your last question, using POST request is OK, but you, as a webmaster, know that it’s possible to “abuse” this option, such as request flooding, etc. But it really is the simplest way.

    If you, by the server side part, parse the data correctly, and check for any improper use of the request, then you can use this method without any problems.

    And last, as you are a C++ beginner, you’ll need to know how to manipulate std::strings for parsing the song name and artist to the post POST message string safely, if you don’t know yet, I recommend this link.

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

Sidebar

Related Questions

Making a mobile friendly site, I have a single field and a submit button.
Im making slide show with jquery How i can set interval between two function
Making a ternary logic table, and I would like to make my own function
Making a simple plugin , which executes javascript when a page is loaded ,
Making lots of progress in a rails 3.1 to 3.2.6 upgrade for a Heroku
Making a new site but something is happening to it in IE8. The social
Making a word document of our network set-up. We have about 7 servers and
Making a new site but something is happening to it in IE. I've purchased
Making a simple application, so when the user logs out of Windows, it of
Making an adobe flex ui in which data that is calculated must use proprietary

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.