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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T14:21:19+00:00 2026-06-14T14:21:19+00:00

I’m trying to open socket. But it gives a link Error (LNK2019 : unresolved

  • 0

I’m trying to open socket. But it gives a link Error (LNK2019 : unresolved external symbol ‘symbol’ referenced in function ‘function’) at WSASTartup, WSAGetLastError, socket, htons. What I’m doing wrong?

Here is a source code

#include <iostream>
#include <string>
#include <winsock2.h>
#include <Windows.h>
using namespace std;
string server; int port;
void login_info()
{
    cout << "Enter IP Address: ";
    cin >> server;
    cout << "\nEnter Port: ";
    cin >> port;
    cout << endl;
}

int main () 
{
    char buffer[1024];
    login_info();
    cout << "Trying to connect...\n";
    if (WSAStartup(0x202, (WSADATA *) &buffer[0])) //Оно что-то запускает. Знать бы что..
    {
        cout << "WSAStart error #" << WSAGetLastError(); //Но если оно пизданётся, то появится ошибка :3
        return -1;
    }
    //Тут предположительно поднимается сам сокет.
    SOCKET connection;
    connection=socket(AF_INET, SOCK_STREAM, 0);
    //Проверка на то, что он есть?
    if (socket<0) 
    {
        cout << "Socket error #" << WSAGetLastError(); //Но если оно пизданётся, то появится ошибка :3
        return -1;
    }
    sockaddr_in dest_addr; //Тут опять происходит, что-то мне непонятное..
    dest_addr.sin_family=AF_INET;      
    dest_addr.sin_port= htons (port);
    HOSTENT *hst;
    return 0;
}
  • 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-14T14:21:20+00:00Added an answer on June 14, 2026 at 2:21 pm

    I think you need to link in the winsock ws_32.lib library. I’m not sure what tool/ide you are using but how to link winsock.lib? has some details.

    MSDN : http://msdn.microsoft.com/en-us/library/windows/desktop/ms737629(v=vs.85).aspx

    Edit – Might need to look for Ws2_32.lib now.

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to construct a data frame in an Rcpp function, but when I
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I want to count how many characters a certain string has in PHP, but
I am trying to render a haml file in a javascript response like so:
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this

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.