Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. VC++ console application - client / Server

VC++ console application - client / Server

Scheduled Pinned Locked Moved C / C++ / MFC
sysadminquestionc++
21 Posts 5 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Pouria Polouk

    It's confusing! Let’s imagine my public IP address is 86.57.91.237. Now I want to use that IP in the code below: ... WSAData ws; struct sockaddr_in sock; int resSock, bnd; WSAStartup(MAKEWORD(2, 2), &ws); resSock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); if (resSock != INVALID_SOCKET){ sock.sin_family = AF_INET; sock.sin_port = htons(3377); sock.sin_addr.S_un.S_addr = inet_addr("86.57.91.237"); } bnd=bind(resSock, (struct sockaddr *)&sock, sizeof(sock)); if (bnd != SOCKET_ERROR) cout << "Bind Successful" << endl; else cout << GetLastError() << endl; ... why does this program show error code 10049? Error code 10049 means: “The requested address is not valid in its context. This normally results from an attempt to bind to an address that is not valid for the local computer”. I want to see “Bind Successful” message.

    J Offline
    J Offline
    jeron1
    wrote on last edited by
    #21

    Run "ipconfig /all" at the command prompt. Look at the results, there should be data given about each NIC card on YOUR machine. Look at the line that says "IP Address.......xxx.xxx.xxx.xxx" (there may be several). Make a list of these IP addresses. If "86.57.91.237" is not in that list, then you can not bind to it. Meaning it is not an IP address associated with a NIC on your computer.

    "the debugger doesn't tell me anything because this code compiles just fine" - random QA comment "Facebook is where you tell lies to your friends. Twitter is where you tell the truth to strangers." - chriselst

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups