Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


winsock errors

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
oib111
I post too much
Reputation: 0

Joined: 02 Apr 2007
Posts: 2947
Location: you wanna know why?

PostPosted: Thu Jun 12, 2008 8:22 am    Post subject: winsock errors Reply with quote

I'm learning winsock from msdn.com and so I've been using their code up to about the accepting a connection from a client and I tried to compile and I got a bunch of linking errors. I think it has to do with WS2_32.lib. But it's in the SDK's Lib folder, and I have my VC++ Directories pointing at that folder in the Lib section. I don't think it's my code, but just incase.

Code:

#include <winsock2.h>
#include <ws2tcpip.h>
#define DEFAULT_PORT "27015"

int main() {
   WSADATA wsaData;
   int Result = WSAStartup(MAKEWORD(2, 2), &wsaData);
   if(Result != 0) {
      return 0;
   }
   struct addrinfo *result = NULL, *ptr = NULL, hints;
   ZeroMemory(&hints, sizeof(hints));
   hints.ai_family = AF_INET;
   hints.ai_socktype = SOCK_STREAM;
   hints.ai_protocol = IPPROTO_TCP;
   hints.ai_flags = AI_PASSIVE;
   Result = getaddrinfo(NULL, DEFAULT_PORT, &hints, &result);
   if(Result != 0) {
      WSACleanup();
      return 1;
   }
   SOCKET ListenSocket = socket(result->ai_family, result->ai_socktype, result->ai_protocol);
   if(ListenSocket == INVALID_SOCKET) {
      freeaddrinfo(result);
      WSACleanup();
      return 1;
   }
   Result = bind(ListenSocket, result->ai_addr, (int)result->ai_addrlen);
   if(Result == SOCKET_ERROR) {
      freeaddrinfo(result);
      closesocket(ListenSocket);
      WSACleanup();
      return 1;
   }
   if(listen(ListenSocket, SOMAXCONN) == SOCKET_ERROR) {
      closesocket(ListenSocket);
      WSACleanup();
      return 1;
   }
   return 0;
}

_________________


8D wrote:

cigs dont make people high, which weed does, which causes them to do bad stuff. like killing
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
Renkokuken
GO Moderator
Reputation: 4

Joined: 22 Oct 2006
Posts: 3249

PostPosted: Thu Jun 12, 2008 8:28 am    Post subject: Reply with quote

It'd be nice to provide the "bunch of linking errors."
Back to top
View user's profile Send private message
lurc
Grandmaster Cheater Supreme
Reputation: 2

Joined: 13 Nov 2006
Posts: 1900

PostPosted: Thu Jun 12, 2008 8:29 am    Post subject: Reply with quote

Code:
#pragma comment ( lib, "Ws2_32.lib" )

_________________
Back to top
View user's profile Send private message
oib111
I post too much
Reputation: 0

Joined: 02 Apr 2007
Posts: 2947
Location: you wanna know why?

PostPosted: Thu Jun 12, 2008 8:33 am    Post subject: Reply with quote

Ok, I still get two errors though.

Code:

------ Build started: Project: winsock, Configuration: Debug Win32 ------
Linking...
MSVCRTD.lib(crtexew.obj) : error LNK2019: unresolved external symbol _WinMain@16 referenced in function ___tmainCRTStartup
C:\Documents and Settings\OIB\My Documents\Visual Studio 2008\Projects\winsock\Debug\winsock.exe : fatal error LNK1120: 1 unresolved externals
Build log was saved at "file://c:\Documents and Settings\OIB\My Documents\Visual Studio 2008\Projects\winsock\winsock\Debug\BuildLog.htm"
winsock - 2 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

_________________


8D wrote:

cigs dont make people high, which weed does, which causes them to do bad stuff. like killing
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
Renkokuken
GO Moderator
Reputation: 4

Joined: 22 Oct 2006
Posts: 3249

PostPosted: Thu Jun 12, 2008 8:36 am    Post subject: Reply with quote

It looks like you're using a console's entry point on a win32 windows application. Either change subsystem to console, or use WinMain.
Back to top
View user's profile Send private message
oib111
I post too much
Reputation: 0

Joined: 02 Apr 2007
Posts: 2947
Location: you wanna know why?

PostPosted: Thu Jun 12, 2008 8:39 am    Post subject: Reply with quote

Thank's Renko. It's working now.
_________________


8D wrote:

cigs dont make people high, which weed does, which causes them to do bad stuff. like killing
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
Renkokuken
GO Moderator
Reputation: 4

Joined: 22 Oct 2006
Posts: 3249

PostPosted: Thu Jun 12, 2008 8:40 am    Post subject: Reply with quote

Glad to help.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites