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 8159225
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T17:50:32+00:00 2026-06-06T17:50:32+00:00

um, first post here, this place seems to be all over google and i

  • 0

um, first post here, this place seems to be all over google and i can usally find my solution with having to acually ask a question my self in any site/forums; but if i sweat any more bullets over this ima hunt down whoever developed winsock and shoot them (sorry for the anger i think ive turned over every rock in every corrner of the net with no luck…. breeaatheee…. wheew)

Im new to network programming, but have been working with C++ for the last three years on a hobby level, and also been playing with AS3 recently.

Im trying to write a server (for the client with is the AS3 project im also working on) and as far as i can tell this SOCKET is perfectly fine. im not re-creating it, multi-threading with it, no re-assignment or anything. no funny bisuness. simply trying to set it all up and bind() is spitting out that nasty 10038 right in my face.

Ive looked on MSDN, and i know very well that 10038 means “attempted operation on an invalid socket”; for the life of me i cant see where its invalid.

but enough of my rambling, heres the code: (functions.h is empty, havnt got that far along yet)

 //Server for Project7 - Client written in AS3 under FlashDevelop. Developed under and for the Windows Operating System Enviroment
//All connections handled under TCP/IP on port 3011
//Client is URL locked to www.cutdev.com
//Copyright Tyler Buchinski 2012 All Rights Reserved
#include <iostream>
#include "functions.h"

#define WIN32_MEAN_AND_LEAN

#include <winsock2.h>
#include <windows.h>


        using namespace std;

int main()
{

    const int iReqWinsockVer = 2;   // Minimum winsock version required

WSADATA wsaData;

  if (WSAStartup(MAKEWORD(iReqWinsockVer,0), &wsaData)==0)
  {
    // Check if major version is at least iReqWinsockVer
    if (LOBYTE(wsaData.wVersion) >= iReqWinsockVer)
    {

        SOCKET SocketListen;
        SocketListen = (AF_INET,SOCK_STREAM,IPPROTO_TCP);


            if(SocketListen == INVALID_SOCKET)
                {
                    cout << "ERROR - could not creaate listening socket." << endl;
                    system("pause");

                    return 4;
                }

            sockaddr_in Listener, Channel1;

            Listener.sin_family = AF_INET;
            Listener.sin_port = htons(3011);
            Listener.sin_addr.S_un.S_addr = INADDR_ANY;

            int err = bind(SocketListen,(sockaddr*)(&Listener),sizeof(Listener));
            if (!err == 0)
                {
                    cout << "Listener binding failed!" << endl;
                    cout << err << endl;
                    cout << WSAGetLastError();

                    return 3;
                }



    }
    else
    {
        // Required version not available
        cout <<"Required version of Winsock not installed." << endl;
    }

    // Cleanup winsock
    if (!WSACleanup() == 0)
    {
        // cleanup failed
        cout << "WSACleanup Failed!!" << endl;
        system("pause");
    }
  }
  else
  {
    cout << "WSA Startup failed!" << endl;
  }
    return 0;
}

Thanks in advance for any help!
-Tyler

  • 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-06T17:50:33+00:00Added an answer on June 6, 2026 at 5:50 pm

    Error 10038 is WSAENOTSOCK:

    An operation was attempted on something that is not a socket.

    This error is returned if the descriptor in the s parameter is not a socket.

    This happens since you omitted the call to socket() and SocketListen contains the value of the IPPROTO_TCP constant instead of a socket descriptor:

    SocketListen = (AF_INET,SOCK_STREAM,IPPROTO_TCP);
    

    should become:

    SocketListen = socket(AF_INET,SOCK_STREAM,IPPROTO_TCP);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My first post here! Seems like this is the place to get wise ;)
My first post here, so i hope this is the right area. I am
This is my first post here so go easy. I am trying to build
This is my first post here. I have a problem. I need to take
this is my first post here on stackoverflow and am very impressed by the
I'm new to Java and this is my first post on here so hopefully
This is my first time here so I hope I post this question at
This is my first post here - so be gentle :-) I want to
This is my first post here, and i should advise that my knowledge is
This is my first post here. I am writing a program in C++ using

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.