Advertisement Jump to content
Sign in to follow this  
Alpha Nox

Winsock Problems(need help badly)

This topic is 4876 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello, Since, I decided to begin learning Winsock, I'm having several problems. I'm using Visual Studio .NET 2003. I'm reading this tutorial: I managed to connect the client and the server through winsock but I'm having difficulties with sending and receiving. 1. I tried to use the readLine() function that the tutorial shows but I had no luck, it just says that recv() didnt received anything, but when I'm normally try to receive it runs fine. 2. I was wondering how would I send an integer and receive it, I asked in the Gamedev chat room, but still couldnt do it. 3. I was having small problems using the code in the tutorial with a console it keeps giving me this error: LIBCMTD.lib(crt0.obj) : error LNK2019: unresolved external symbol _main referenced in function _mainCRTStartup Debug/phoenixSERVER.exe : fatal error LNK1120: 1 unresolved externals I tried to do as Drew_Benton here in the forum said, he said to add this at the top: #pragma comment( linker, "/entry:\"WinMainCRTStartup\"" ) But the problem continues. I would really like some help with this, if there is a better tutorial that works perfectly with VS.NET 2003, could you please tell me? I'm really confused with Winsock(I can't afford to buy a Winsock book) and sorry with I'm making silly mistakes, I'm doing my best. Thanks very much, Victor Freire

Share this post

Link to post
Share on other sites
You can take a look at my Socket Layer for my custom MUD engine. It uses a basic TCP implementation, and works on both Unix and Windows (there are seperate definitions for the class for each). There are some portions on the basic raw socket reading, sending, and parsing.

To send an integer across the network, the following bit below should work. Mind you, I haven't tested this, and its just a guess. I'm also assuming that you're using C++ (for the reinterpret_cast) if not, you should be able to use a regular typecast to char*:

int i = 10;
send( Socket, reinterpret_cast<char*> ( &i ), sizeof( int ), 0 );
The third sounds like that you do not have a int main() in your program. I haven't checked the website (actually need to run quick) so you should probably make sure there is not a WinMain. If there is, you can do the following to change the project to a Windows Application:

Right click on the name of the project in the Solution Explorer, and click Properties (or you should be able to access it through the project properties in the menus).

Go to the Linker folder, and then to the System tab. Change the Subsystem (first entry) from CONSOLE to WINDOWS. This will require WinMain instead of main() as the application's calling point.

This works in Visual C++ 7.1 .NET 2003; its what I have, but should be very similar for 7.0 .NET 2002.

Good Luck!

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!