Do I need to download a library for using sockets on Windows?

  • Thread starter Thread starter sneez
  • Start date Start date
  • Tags Tags
    Windows
Click For Summary

Discussion Overview

The discussion revolves around the requirements for using sockets in Windows programming, specifically focusing on the necessary libraries and linking processes involved when using the WSAStartup function.

Discussion Character

  • Technical explanation
  • Debate/contested

Main Points Raised

  • One participant inquires about the library needed to link for the WSAStartup function, questioning whether it is included with Windows or needs to be downloaded.
  • Another participant suggests that the WSAStartup API is part of the WS2_32.DLL library, providing a link to MSDN for further information.
  • A different participant mentions having the WS2_32.DLL file but encounters a linking error when compiling, expressing confusion about the issue.
  • One response assumes the user is programming in C# or C++, stating that the compiler must be instructed to include the library, although the exact method is not clearly recalled.
  • Another participant clarifies that the .dll is not a library but a shared object, emphasizing the need to link against the corresponding .lib file (Ws2_32.lib) instead, and provides a path where this file can be found on their system.
  • A participant expresses gratitude for the help received.

Areas of Agreement / Disagreement

The discussion contains multiple viewpoints regarding the linking process and the distinction between .dll and .lib files, with no consensus reached on the exact steps to resolve the linking error.

Contextual Notes

There are unresolved aspects regarding the specific compiler error mentioned by one participant, as well as the exact method for including the library in the compilation process.

sneez
Messages
312
Reaction score
0
Im trying to play with sockets on windows

what lib do i need to link to make this statement work? Does it come with win or do i have to download it?



WSAStartup(MAKEWORD(1,1), &wsa);
 
Computer science news on Phys.org
Thanx enathan, i have that library in my windows/system32 dir but when i try to compile program using the above code it says link error.

Why is that. I can use socket dlls and stuff but not this ? something I am doing wrong...?
 
I am assuming you are using C# or C++

You have to tell the compiler to include the library somehow. I think the keyword (or drective) is #Include <library>; I forget lol I have not programmed C# for a long time.

What exactly is the compiler error BTW?
 
The .dll is not a library -- it's a shared object. You need to link against the .lib file corresponding to the .dll, which provides all the signatures for linking. You also do not use the #include directive for anything involving libraries; the #include directive affects the source, and only the compiler deals with the source itself. The linker deals with the resulting object files, and has nothing to do with the source.

You need to link against the library Ws2_32.lib, present (on my Windows XP SP2 machine) in C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Lib

In the future, please use MSDN to search for documentation: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winsock/winsock/wsastartup_2.asp

- Warren
 
Last edited by a moderator:
thanx a lot

:d
 

Similar threads

  • · Replies 4 ·
Replies
4
Views
3K
Replies
2
Views
4K
  • · Replies 13 ·
Replies
13
Views
2K
  • · Replies 5 ·
Replies
5
Views
4K
Replies
2
Views
2K
  • · Replies 37 ·
2
Replies
37
Views
7K
  • · Replies 18 ·
Replies
18
Views
4K
Replies
9
Views
3K
Replies
1
Views
2K
Replies
4
Views
3K