News:

When registered with our forums, feel free to send a "here I am" post here to differ human beings from SPAM bots.

Main Menu

Linking winsock

Started by Schtee, November 24, 2006, 12:26:10 PM

Previous topic - Next topic

Schtee

Hi there.
I'm trying to make a project using winsock. I've tried to link "libws2_32.a" via: Project -> Build options -> Linker tab. When I go to compile I receive the following error:
File       Message
ld.exe    cannot find -lsw2_32.lib

Any ideas? Thanks a lot.

MortenMacFly

Quote from: Schtee on November 24, 2006, 12:26:10 PM
ld.exe    cannot find -lsw2_32.lib
There is no such lib "sw2_32.lib", only "w2_32.lib". ;-)
With regards, Morten.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: [url="https://www.codeblocks.org/docs/main_codeblocks_en.html"]https://www.codeblocks.org/docs/main_codeblocks_en.html[/url]
C::B FAQ: [url="https://wiki.codeblocks.org/index.php?title=FAQ"]https://wiki.codeblocks.org/index.php?title=FAQ[/url]

Schtee

#2
Which led to my confusion. I'm only trying to link libws2_32. There's no reference I can find to sw2_32.lib, w2_32.lib or anything else.

**EDIT:** After some poking around I found that I had the wrong library under the - Console Application -> Default profile. My bad, sorry.

Ecliptic Fate

good lord what a pain network programming is to learn.


just thought i would drop a hint here.

ws2_32.lib worked for me using the ms toolkit 2003 by adding it as an external dependency under the project properties.

I first attempted GCC and putting it in the linker tab under build options like it mentions above. got nothing.

I'll be playing with this awhile maybe put up a tut when im done.

joubertdj

#4
Quotegood lord what a pain network programming is to learn.
:?

Anyway, although this is not a general programming board, I will try and be brief. Attached is a server client udp example written with winsock (Not winsock2, there is a difference) and should be linked with libwsock32.a
I am using MingW, hence the a.

Hope it helps.

EDIT: PS Not an expert at this. But a very cool way to "poll" for data in the UDP socket is:


int udpNetworkStack::pollSocketQue()
{

   timePortDelay.tv_sec = 0;
   timePortDelay.tv_usec = 0;

   select(SocketDescriptor+1,&SocketFileDescriptorSet,NULL,NULL,&timePortDelay);

   if (FD_ISSET(SocketDescriptor,&SocketFileDescriptorSet))
   {
      bytesReceived = recvfrom(SocketDescriptor, ReadPacket, PacketSize, 0, (struct sockaddr*)&ClientInformation.networkInformation, &clientLength);
      //Add all the network packets in the que to the linklist
      return(1);
   }
   return(0);
}


[attachment deleted by admin]