# Consoles and Winsock2

## Recommended Posts

I've just finished reading the long article on using Winsock2 with C++ . I learned some things from it but not enough to go through the Main.cpp and delete all the miscellanious DirectX code and have the bare Winsock2 stuff and be able to use it with a (I think) Win32 Console Application. So how do I use the winsock stuff with the console app? I'm trying to make a MUD (the MUD book didn't make sense to me on how to set up the Winsock stuff, so unless you can explain how to get me started with it don't post a link saying read this). Just a .cpp with a very simple console application input ouput multi-user would help me out a lot as a kind of 'template' to help me learn. Thx

#### Share this post

##### Share on other sites
Look for a BSD sockets example program. Use that, as Winsock is just a minor variation on the same theme.

#### Share this post

##### Share on other sites
Except that you need to call WSAStartup() first.

#### Share this post

##### Share on other sites
Thanks guys I'll start researching BSD, and since you said BSD is similar to WinSockets does that mean that it will not work on other operating systems besides Windows 95 and above as well?

#### Share this post

##### Share on other sites
Beej's Guide to Network Programming is rather popular and a good starting point, imo.

#### Share this post

##### Share on other sites
Thanks I think that's what I was looking for more than BSD. I searched up BSD and it's an operating system?

#### Share this post

##### Share on other sites
Again with this problem =( There's always the step you have to do so everything works under project settings and something else. But I can't find where that is. Not even my dad could find it and he works for Microsoft doing stuff with Visual Studios. So where is it? A hotkey to use it or anything?

#### Share this post

##### Share on other sites
Quote:
 There's always the step you have to do so everything works under project settings and something else.

It would be a lot easier to help if you told us what you were actually trying to do...

All you have to do to 'setup' winsock in MSVC++ is this...
#include <winsock2.h>#pragma comment( lib, "WS2_32.lib" )

#### Share this post

##### Share on other sites
Thanks Deyja that helps out, and btw I did say what I was trying to do:

"I'm trying to make a MUD" was in my first post. Which means I'm trying to make a multiplayer MUD.

#### Share this post

##### Share on other sites
Quote:
 Original post by WoadThanks Deyja that helps out, and btw I did say what I was trying to do:"I'm trying to make a MUD" was in my first post. Which means I'm trying to make a multiplayer MUD.

Granularity. Given that making a MUD involves a ton of things that have nothing to do with networking and/or sockets, clearly that's a useless piece of information in this context. If you want quick and accurate help, you have to learn to give detailed and relevant information. Call it fair exchange, if you will.

#### Share this post

##### Share on other sites
Well I was thinking it may be obvious enough to post about winsockets in the networking section and say I was making a MUD using Win32 Console App and have people understand i'm making a multiplayer text-based MUD . Next time I'll try to be more specific.

#### Share this post

##### Share on other sites
I believe everyone is referring to this post, not the original post:

Quote:
 Original post by WoadAgain with this problem =( There's always the step you have to do so everything works under project settings and something else. But I can't find where that is. Not even my dad could find it and he works for Microsoft doing stuff with Visual Studios. So where is it? A hotkey to use it or anything?

"the step you have to do so everything works" is incredibly vague. You don't mention what isn't working, so of course we can't tell you how to fix things.

#### Share this post

##### Share on other sites
I'm assuming that you are trying to build the project, and you get errors.

For us to diagnose the errors, you need to copy the first few errors from the build output window, and paste them into your question.

You then have to copy the 10 lines around the area of the error in the source, and paste those, too. If those lines make reference to globals or custom data structures of yours, it would help to paste the definition of those, too.

Then, we can see what the problemis (the errors) and what the solution might be (your code). Asking for help without that information is like asking us to read your mind.

#### Share this post

##### Share on other sites
I could read your mind, but you won't like what you're thinking.

#### Share this post

##### Share on other sites
No errors, I know I should post the part of the code I think is causing the problem and then post what the output window said the error(s) were.
*The step that makes everything work* is the step where you must click on the Project->Settings->All Configuration->Object Modules/something I forgot
I can't remember the exact step but a lot of tutorials say you need to do that, in fact Deyja solved the problem by just posting the code that does that, all tutorials say you can find it in some window somewhere (I know you probably can't understand anything after that comma but if you can then thumbs-up for you).
THAT was the problem (If there was some options to bold or underline i'd do that instead of caps).

#### Share this post

##### Share on other sites
You will need to include the Winsock runtime library in your project.

About your signature: Why are you so confident so many people hate your country? Have you ever talked to them or visited their country?

#### Share this post

##### Share on other sites
Quote:
 Original post by GoldfishAbout your signature: Why are you so confident so many people hate your country? Have you ever talked to them or visited their country?

it seems that he is rather selfish and/or confuses reality with movies..
also, I think it's stupid people like him who hates the rest of the world and not the other way around..

but let's try not to get offtopic..

## Create an account or sign in to comment

You need to be a member in order to leave a comment

## Create an account

Sign up for a new account in our community. It's easy!

Register a new account

## Sign in

Already have an account? Sign in here.

Sign In Now

• ## Partner Spotlight

• ### Forum Statistics

• Total Topics
627689
• Total Posts
2978648

• 13
• 14
• 12
• 10
• 12