WinSock Problem

This is a discussion on WinSock Problem within the C++ Programming forums, part of the General Programming Boards category; Hi! I create new Win32 Console application, and type this code: ------------------------------------------- #include <iostream.h> #include <winsock2.h> void main() { //Must ...

  1. #1
    Registered User
    Join Date
    Oct 2001
    Posts
    104

    Unhappy WinSock Problem

    Hi!

    I create new Win32 Console application, and type this code:
    -------------------------------------------
    #include <iostream.h>
    #include <winsock2.h>


    void main()
    {
    //Must be done at the beginning of every WinSock program
    WSADATA w; //Used to store information about the WinSock version
    int error = WSAStartup(0x0202,&w); //Fill in w

    if(error) //there was an error
    cout << "There was an error!\n";

    if(w.wVersion != 0x0202)
    { //wrong version
    WSACleanup(); //Unload ws2_32.dll
    return;
    }
    }

    ---------------------------

    When I compile it, I get this error:
    -----------
    ss1.obj : error LNK2001: unresolved external symbol __imp__WSACleanup@0
    ss1.obj : error LNK2001: unresolved external symbol __imp__WSAStartup@8
    Debug/ss1.exe : fatal error LNK1120: 2 unresolved externals
    ----------

    I am using VC++ 6.

    Anyone has idea? Why do I get these errors?

    Thanks!
    Ilia Yordanov,
    http://www.cpp-home.com ; C++ Resources

  2. #2
    Programming is fun, mkay?
    Join Date
    Oct 2001
    Posts
    490

    Wink Try this...

    Try linking to the winsock library. I think it's wsock32
    Website(s): http://www16.brinkster.com/trifaze/

    E-mail: trifaze_mattu@lycos.com

    ---------------------------------
    C++ Environment: MSVC++ 6.0; Dev-C++ 4.0/4.1
    DirectX Version: 9.0b
    DX SDK: DirectX 8.1 SDK

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Winsock issues
    By tjpanda in forum Windows Programming
    Replies: 3
    Last Post: 12-04-2008, 07:32 AM
  2. Where do I initialize Winsock and catch messages for it?
    By Lithorien in forum Windows Programming
    Replies: 10
    Last Post: 12-30-2004, 11:11 AM
  3. Winsock packet problem
    By Rare177 in forum Windows Programming
    Replies: 7
    Last Post: 10-05-2004, 04:53 PM
  4. Winsock Problem
    By Noxir in forum C++ Programming
    Replies: 4
    Last Post: 07-18-2004, 10:50 AM
  5. Small Winsock problem...
    By SyntaxBubble in forum C++ Programming
    Replies: 0
    Last Post: 02-09-2002, 09:09 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21