User forums > Help
Linking winsock
(1/1)
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
--- End quote ---
There is no such lib "sw2_32.lib", only "w2_32.lib". ;-)
With regards, Morten.
Schtee:
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:
--- Quote ---good lord what a pain network programming is to learn.
--- End quote ---
:?
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:
--- Code: ---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);
}
--- End code ---
[attachment deleted by admin]
Navigation
[0] Message Index
Go to full version