hi,
i have develeop the game on c++ with allegro now i want to make multi player means connect 2 pc through internet by ip address ...
how to make this please help me ....
If I understood your situation properly, I can strongly advice learning Windows Socket Programming. I have included some links which may help you with this:
_______________________________________________
Server (Transmission Control Protocol based) : http://www.youtube.com/watch?v=jBAAbp6cNpg
Client (Transmission Control Protocol based):
http://www.youtube.com/watch?v=IY5IyX_KFJk
_______________________________________________
Of course as you are developing Network\ Multiplayer capabilities I think User Datagram Protocol type server & client will be useful:
http://www.youtube.com/watch?v=IqzqiI0kMk4
hi SpaceWorm,
me watched that video on link you provide but not fulfilling my problem please give me another complete solution in source code something else....
i have not much time to do this i have to submit my project by thursday 2:00 p.m...and project covering my 50% course marks...
so please do my help to done this as soon as possible i be great thankful to you ...
regards
karan
@ SpaceWorm: void main()? Really? If you're using namespaces then you're writing in C++, you should follow the standard. Everything else was great.
Part 1: This tutorial was a beautiful start, I thought using comments and text would get annoying but you type well enough that it works. I especially liked the use of Telnet to bring it all together, it shows the watcher that they are making a functional application. I'm a little surprised to see that you didn't cover "send()" or "recv()" right here.
Part 2: The Red on Black needs to die. It's not unwatchable but it is distracting. When using the "send()" function you should take advantage of the strings library which you've already included. Things like the ".length()" member function allow the user to enter whatever message they want and they don't have to adjust the size of the buffer by hand. The "infinite for loop" looks a little amateurish, and you'll notice it didn't work. I would suggest do{ /*code code code*/ }while(message != "Quit");.
Server-Client applications are a great place to see the advantages of multi-threading. If you think it's too much for most people to take in at once then I can see that as a valid argument. But if you're looking to redo these or try your hand at a part 3 and\or 4 then that would be useful add-on.
@kbw
thanks for help ,but sir i have not much tie read this now i have submit my project by 2 pm please give me only complete solution so i can apply and submit my project....??
If you think that someone giving you an entire solution that you can readily pass off as you're own work then I seriously believe you've missed the point of your education.
@kbw: Not exactly constructive criticism there is it? Video is a terrible medium for teaching anything but given that it was a 20 min shotgun lesson I think he did pretty good. Saying you need to understand sockets before you use them is like saying you need to understand iostream before writing Hello World. I learned what I know by working backward from functional code, and Im just getting around to authentication now.
EDIT: karan124: I could help you out. It would only cost you 5 Bitcoins.
I just don't think his attempt is a total loss. I think with a few pointers here and there would make this one of the few passable video tutorials on YouTube. I'm also kind of hijacking the thread since the OP has no intention of trying to learn anything. That is a good link you posted but it's a POSIX tutorial. You don't need Cygwin to write networking code in Windows.
hello,
please help me to done my project ...i read all links but still confused to done my project please send me code of multiplayer game in c++ please so get through that one and do my project....
i try my best to do this but can't getting result....therefore i want best solution...
otherwise i developed game so can do any thing else also but this going out of mind....
so help me....really want this not only for project but i want to learn this really
int main(int argc, char* argv[])
{
int nRetCode = 0;
char buf[4096];
cout << "Press ONLY ENTER to quit.\n";
cout << "=================================================\n";
if(!CServerObj.IsConnected())
{
cout<<"\nFailed to initialise server socket";
cout<<"\nThis is boby signing off : Bye";
getch();
return 1;
}
AfxBeginThread(ServerListenThread,0);
while(gets(buf))
{
if(strlen(buf) == 0)
break;
if(CServerObj.SendMessagePort(buf))
{
cout<<"Problem in connecting to server.\n";
break;
}
}
int main(int argc, char* argv[])
{
char buf[4096];
cout<<"\nPress ONLY ENTER to quit\n\n";
FILE *fp = fopen("server.ini","r");
if(fp == NULL)
{
cout<<"\nUnable to open server.ini. Please specify server IPsddress in server.ini";
return 1; // main failed
}
string sServerAddress;
while((fgets(buf,4096,fp)) != NULL)
{
if(buf[0] == '#')
continue;
sServerAddress = buf;
}
fclose(fp);
if(sServerAddress.size() == 0)
{
cout<<"\nUnable to find server IPaddress in server.ini";
cout<<"\nPlease set server IPaddress";
cout<<"\nThis is user Signing off.";
getch();
return 0;
}
MyMessObj.Init(sServerAddress.c_str(),8084);
if(!MyMessObj.IsConnected())
{
cout<<"\nUnable to connect to the IPaddress specified in server.ini";
cout<<"\nPlease check server IPaddress";
cout<<"\nThis is user Signing off. BYE:";
getch();
return 0;
}
AfxBeginThread(MessageRecThread,0);
while(gets(buf))
{
if(strlen(buf) == 0)
break;
if(MyMessObj.SendMessagePort(buf))
{
cout<<"Problem in connecting to server. \n";
break;
}
}
cout<<"\nThis is user Signing off. BYE:";
getch();
return 0;
}
What it should do depends on how you want you chat thing to work. Do peers chat to each other one on one, or you they chat in a forum hosted on the server?
You seem to pretty much have all the comms code and thread stuff (perhaps too many). But it's not connected up properly.
If you could describe in detail how you expect it work (in words), I might have a better idea of what you're trying to do and help you connect the parts together.
You have to remember that the client and server work together. They have to agree on when data is to be send and received and what is communicated. You don't seem to cover that area very well.