-1

I've also tried linking with the path on my computer which is

C:\Qt\Tools\mingw48_32\i686-w64-mingw32\lib\libws2_32.a

but to no avail.

Is there any other way to link the winsock library?

Source code:

.pro file: http://privatepaste.com/2ac921e4f5

main.cpp: http://privatepaste.com/557fe9c297

These are the only two files that aren't at their original settings.

user3376098
  • 39
  • 2
  • 7

1 Answers1

0

Are you using this example

Instead of pragma you could just add it using Project Properties (in Solution Explorer right click the project name and select properties)->Configuration Properties->Linker->Input and add ws2_32.lib to Additional Dependencies. In VS2010 this is a semicolon seperated list, so at the end, just before %(AdditionalDependencies), add ws2_32.lib; to the list.

THIS IS YOUR CODE

s1 = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); 
a.sin_addr.s_addr = inet_addr("127.0.0.1"); 
a.sin_family = AF_INET; 
a.sin_port = htons(1000);

a doesn't have those methods, the socket does, replace a with s1 please

The same goes for this:

lLength = connect(s1, (SOCKADDR*)&a, sizeof(a));

just a question

Why are you passing the main window

MainWindow w; 
w.show(); 
iResult = WSAStartup(MAKEWORD(2,2), &w);

to your WSAStartup??

Pass a WSADATA wsaData;

Community
  • 1
  • 1
Claudiordgz
  • 3,023
  • 1
  • 21
  • 48