-
November 4th, 2008, 01:58 AM
#1
C++ Sockets
Hi guys.
I'm wondering how you can make multi-user sockets in C++? I use DevCPP, I know what it has stopped DEV though I still like to use it.
In VisualBasic 6 You have "Indexs" is there a way you can do this so in C++, like in VB6 on Connection_Request you assign it a new index (Unload Socket(NewIndex), Then Load Socket(NewIndex)?).
So, what shall I do? I don't want code::blocks please.
Thanks guys.
-
November 4th, 2008, 06:03 AM
#2
Re: C++ Sockets
I like very much Dev-cpp too. I still use it. I don't think it is really necessary to switch to code::blocks, because it is working with the same Mingw compiler.
Sorry, I don't know LoadSocket.
In C/C++, sockets can be used in many different ways (send or receive, UDP or TCP, retrieve data with recvfrom() or another function, etc.). You don't tell much about what you intend to do with sockets. Maybe a solution would be to have sockets on different ports, or to use threads, or to write data in a file and have access to that file from several applications, etc.
-
November 4th, 2008, 11:37 AM
#3
Re: C++ Sockets
What do you mena by a "multi-user socket"? Ordinarily, one socket will talk only to one other socket, not to multiple other sockets.
If you want a program that will talk to multiple other parties, then the common approach is to create multiple sockets, each for talking with one other remote participant.
-
November 4th, 2008, 04:39 PM
#4
Re: C++ Sockets
This is where I learned most of what I know about socket programming:
http://beej.us/guide/bgnet/
I feel like a hypocrite as I can't stand when people just reply to a post with just a link, but that tutorial is very handy.
A good idea is to make yourself a class so you can easily reuse it and not have to remember all the code behind it. You'll need a client class and a server class (and possibly other classes that work together depending how you do it).
But to at least get your feet wet just play around with the code in that tutorial.
-
November 15th, 2008, 07:08 PM
#5
Re: C++ Sockets
Sorry for the slow reply,
I'm trying to make a basic game server in C++, because I've made a game client in Flash/Actionscript.
It needs to be able to talk to multiple sockets, any help?
-
November 15th, 2008, 11:20 PM
#6
Re: C++ Sockets
Originally Posted by markh789
Sorry for the slow reply,
I'm trying to make a basic game server in C++, because I've made a game client in Flash/Actionscript.
It needs to be able to talk to multiple sockets, any help?
General Server configuration.
1) A single socked is created to "Listen"
2) When a Connection is Recieved, a NEW Socket is created which "Accepts" the connection. This socket will remain alive as long as THAT client is alive.
3) The original socket goes back to listening.
This means that if you have 1,234 clients playing your game, you have 1,235 sockets at that point in time.
TheCPUWizard is a registered trademark, all rights reserved. (If this post was helpful, please RATE it!)
2008, 2009,2010
In theory, there is no difference between theory and practice; in practice there is.
* Join the fight, refuse to respond to posts that contain code outside of [code] ... [/code] tags. See here for instructions
* How NOT to post a question here
* Of course you read this carefully before you posted
* Need homework help? Read this first
-
November 16th, 2008, 12:12 PM
#7
Re: C++ Sockets
Yes, but recognize that it is quite a challenge to build a server that can handle 1,234 client connections simultaneously.
A few hundred is easy, but it quickly becomes difficult once you start thinking about 1,000 or more.
-
November 16th, 2008, 07:35 PM
#8
Re: C++ Sockets
TheCPUWizard is a registered trademark, all rights reserved. (If this post was helpful, please RATE it!)
2008, 2009,2010
In theory, there is no difference between theory and practice; in practice there is.
* Join the fight, refuse to respond to posts that contain code outside of [code] ... [/code] tags. See here for instructions
* How NOT to post a question here
* Of course you read this carefully before you posted
* Need homework help? Read this first
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|