Advertisement

first winsock

Started by February 24, 2005 05:07 PM
2 comments, last by Sfpiano 19 years, 11 months ago
OS: Windows 2K/XP Compiler: Microsoft Visual C++ 6.0 language: C++ I've been reading about network programming and sockets for about a year and have decided this weekend would be the weekend I write my first succesful socket(let's hope). All the code I find is either for linux, not my compiler, or throw in graphics along with the code making it overwhelming. I've tried picking apart other peoples source code to get it to compile on my computer and have been very unsuccesful. My main problem is I read the articles and tutorials and understand them to some degree but when i try to write my own code I always fail at compile time. Even if I don't alter the code and use as is I always have problems. All I want to do is write a simple two player networked tic tac toe game from the command line in a win32 console application. I would like a simple server and client that will connect and be able to send two variables like int x and int y. if anybody has a simple program like this that they wrote or could point me to a more specific example that would be greatly appreciated. Thank you. I am trying to use winsock2. So I have the ws2_32.dll file and I believe the only #import's I need are #include <winsock2.h> // for the sockets #include <iostream> // for my simple tic tac toe stuff that i don't need help with also i'm a poor college student with no money for books please help
Have you taken a look at these:
http://www.hal-pc.org/~johnnie2/winsock.html
http://www.ecst.csuchico.edu/~beej/guide/net/

I know the second one's for unix, but many of the startup functions are similar of the same. Aside from that, you could post your code and I'd be happy to look at it.
//------------------------------------------------------------------------------------------------------The great logician Bertrand Russell once claimed that he could prove anything if given that 1+1=1. So one day, some fool asked him, "Ok. Prove that you're the Pope." He thought for a while and proclaimed, "I am one. The Pope is one. Therefore, the Pope and I are one."
Advertisement
I have tried reading beej guide before and that's the code my compiler would compile. I like johnnie2's tutorial though, the only problem that I am aware of now is in my main() function. John tells me if I'm using Microsoft VC++ (which I am) then I need to build a Windows project with a WinMain(). So i think I did this right. I created a windows console application, and then I've tried changing his
int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR lpCmd, int nShow)
to just
int WinMain()
and other slight variations but my one compile error says it's not valid. If somebody could help me get this working I would greatly appreciate it.

Also it does not compile with his original WinMain( plus all his parameters )
I don't believe you can change WinMain to just WinMain(), and a WinMain application is not a console application, it's a Win32 windowed application.
//------------------------------------------------------------------------------------------------------The great logician Bertrand Russell once claimed that he could prove anything if given that 1+1=1. So one day, some fool asked him, "Ok. Prove that you're the Pope." He thought for a while and proclaimed, "I am one. The Pope is one. Therefore, the Pope and I are one."

This topic is closed to new replies.

Advertisement