Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Making Visual C++ program web available

Status
Not open for further replies.

dsokyno

IS-IT--Management
Oct 21, 2001
3
0
0
US
What is needed to make a game written in visual C++ avaible via the web? Thanks
 
For games you can use
1. If is a game where interaction speed is critical(Quake, CounterStrike, NeedForSpeed), use UDP protocols or UDP based RCP, or IPX.
2. If you're using game where inetraction speed is not critical, but the acuracy of data is (chess, StarCraft) you can use TCP based protocols.

Ion Filipski
1c.bmp

ICQ: 95034075
AIM: IonFilipski
filipski@excite.com
 
The game is already written in Visual C++. I need a way to convert this code to a web usable application.
 
In Visual Studio on the Project menu choose the Add New Item option. Then in the Add New Item Dialog, select the Web leaf on the tree and from the available items select ATL Server Web Service

-pete
 
Pete, thank you for the help. I have Visual Studio 6.0 Pro. Ed. On the Project menu it has Add to Project option. Then on the Add to Project Menu it has the following options:
New...
New Folder...
File...
Data Connection...
Am I missing something or do I have the wrong version? I did not see on the Project menu:
Add New Item option. Therefore I did not see the Web leaf items the lead to the ATL Server Web Service .
Please help. Thanks
 
>> I have Visual Studio 6.0 Pro. Ed.

Yeah, that’s fairly important information. Since you did not mention that you were using an older version of the product in the original post I just assumed you were using the latest version (Visual Studio 2003).

The ATL Web Service classes were added to the latest release of the product. I have no idea if they are available or compatible with previous versions. If they are I imagine there would be information about that on the microsoft.com web site.


-pete
 
What do u mean by web-usable??

I mean do u want to add Networking function to your app or do u want to turn this app into an ActiveX download or is it simple enough to present an HTML user interface for users to your game that runs on the server-side??

plz clarify.

Rocco is the BOY!!

SHUT YOUR LIPS...
ROCCOsm.gif
 
Yes, I want to make it available via the web. It will be played from my website. I need the best advice I can get to run this game from my server with nice flash interface. Your suggestions is highly appreciated. Thank you for the help.
 
could you say what technology would you like to use? For example I could say you how to start fast in TCP

Ion Filipski
1c.bmp

ICQ: 95034075
AIM: IonFilipski
filipski@excite.com
 
I assume if it is web based the technology or protocol will likely be TCPIP. Or do you have a better idea? I will appreciate the help.
Thanx
 
i give you a short sample of using TCP protocol. If you haev troubles, post them in a new thread:
////////////client////////////////
#include<io.h>
#include<stdio.h>
#include<stdlib.h>
#include<winsock2.h>
#include<windows.h>
#define PORTNUM 888
#include<windows.h>
bool run = true;
DWORD WINAPI ThreadProcToSvr(void* xx)
{
int ns = *(int*)xx;
char buf[80];
while(1)
{
int nbytes = recv(ns, buf, sizeof(buf), 0);
printf(&quot;%s\n&quot;, buf);
if(strcmp(&quot;exit&quot;, buf) == 0)break;
}
run = false;
return 0;
}
DWORD WINAPI ThreadProcCln(void* xx)
{
int ns = *(int*)xx;
char buf[80];
HANDLE hThreadCln = 0;
ULONG th_id;
while(1)
{
gets(buf);
send(ns, buf, sizeof(buf), 0);
if(!hThreadCln)hThreadCln = CreateThread(0, 0, ThreadProcToSvr, (void*)&ns, 0, &th_id);
if(!hThreadCln){printf(&quot;error on creating thread\n&quot;);exit(1);}
if(strcmp(&quot;exit&quot;, buf) == 0)break;
}
run = false;
return 0;
}

int main(HINSTANCE, HINSTANCE, LPSTR, int)
{
WORD wVersionRequested = MAKEWORD( 2, 2 );
WSADATA wsd;
WSAStartup(wVersionRequested, &wsd);

int s;//SOCKET

sockaddr_in svr_addr;//sei-filipski
hostent *hp;
char buf[80] = &quot;salut la toti&quot;;
if((hp = gethostbyname(&quot;icurici&quot;)) == 0)
{
printf(&quot;error on calling gethostbyname()\n&quot;);
exit(1);
}
strncpy((char*)&svr_addr.sin_addr.S_un.S_un_b, hp->h_addr_list[0], hp->h_length);


svr_addr.sin_family = hp->h_addrtype;
svr_addr.sin_port = htons((u_short)PORTNUM);
if((s = socket(AF_INET, SOCK_STREAM, 0)) == -1)
{
printf(&quot;error on creating socket\n&quot;);
exit(1);
}
if(connect(s, (const sockaddr*)&svr_addr, sizeof(svr_addr)) == -1)
{
printf(&quot;error on calling connect()\n&quot;);
exit(1);
}
ULONG th_id;
HANDLE hThreadSvr = 0;
hThreadSvr = CreateThread(0, 0, ThreadProcCln, (void*)&s, 0, &th_id);
if(!hThreadSvr){printf(&quot;error on creating thread&quot;);exit(1);}
while(run);
close(s);
return 0;
}
////////////client////////////////
////////////server////////////////
#include<conio.h>
#include<io.h>
#include<stdlib.h>
#include<stdio.h>
#include<winsock2.h>
#include<windows.h>
//WS2_32.Lib required
#define PORTNUM 888;
//server
bool run = true;
DWORD WINAPI ThreadProcCln(void* xx)
{
int ns = *(int*)xx;
char buf[80];
while(1)
{
gets(buf);
send(ns, buf, sizeof(buf), 0);
if(strcmp(&quot;exit&quot;, buf) == 0)break;
}
run = false;
return 0;
}
DWORD WINAPI ThreadProcSvr(void* xx)
{
int ns = *(int*)xx;
char buf[80];
HANDLE hThreadCln = 0;
ULONG th_id;
while(1)
{
int nbytes = recv(ns, buf, sizeof(buf), 0);
if(!hThreadCln)hThreadCln = CreateThread(0, 0, ThreadProcCln, (void*)&ns, 0, &th_id);
if(!hThreadCln){printf(&quot;error on creating thread\n&quot;);exit(1);}
printf(&quot;%s\n&quot;, buf);
if(strcmp(&quot;exit&quot;, buf) == 0)break;
}
run = false;
return 0;
}
int main()
{
WORD wVersionRequested = MAKEWORD( 2, 2 );
WSADATA wsd;
WSAStartup(wVersionRequested, &wsd);
int s, ns;
int nport;
nport = PORTNUM;
nport = htons((u_short)nport);
sockaddr_in svr_addr, cln_addr;
s = socket(AF_INET, SOCK_STREAM, 0);
if((s = socket(AF_INET, SOCK_STREAM, 0)) == INVALID_SOCKET)
{
printf(&quot;error on calling socket()\n&quot;);
exit(1);
}
svr_addr.sin_family = AF_INET;
svr_addr.sin_addr.S_un.S_addr = (u_long)INADDR_ANY;
svr_addr.sin_port = nport;
if(bind(s, (const sockaddr*)&svr_addr, sizeof(svr_addr)) == -1)
{
printf(&quot;error on calling bind()&quot;);
exit(1);
}
printf(&quot;server ready: %s\n&quot;, inet_ntoa(svr_addr.sin_addr));
if(listen(s, 5) == -1)
{
printf(&quot;error on calling listen()\n&quot;);
exit(1);
}

while(1)
{
int addrlen;
addrlen = sizeof(cln_addr);
if((ns = accept(s, (sockaddr*)&cln_addr, &addrlen)) == -1)
{
printf(&quot;error on calling accept\n&quot;);
exit(1);
}
printf(&quot;client: %s\n&quot;, inet_ntoa(cln_addr.sin_addr));
int nbytes;
char buf[80];
ULONG th_id;
HANDLE hThreadSvr = 0;
hThreadSvr = CreateThread(0, 0, ThreadProcSvr, (void*)&ns, 0, &th_id);
if(!hThreadSvr){printf(&quot;error on creating thread&quot;);exit(1);}
while(run);
close(ns);
close(s);
exit(0);
}
return 0;
}
////////////server////////////////

Ion Filipski
1c.bmp

ICQ: 95034075
AIM: IonFilipski
filipski@excite.com
 
Well if your running an IIS server you can create the app as a dll and run it as a web service - lookup ISAPI i think.
Then it should be easy to use it to create a flash program that calls this dll game.

Rocco is the BOY!!

SHUT YOUR LIPS...
ROCCOsm.gif
 
Pete, I just installed Visual Studio.net 2003. When I tried using the ATL Server Web Service I got this error:&quot;Web service support can only be added to ATL/Server Application DLL projects.&quot; Please help me again. OSR, Ion etc., please continue to help. I highly appreciate all the help. You guys are all great. Thank you
 
it means you can not create it as an .exe, but you could create a .exe DCOM object.

Ion Filipski
1c.bmp

ICQ: 95034075
AIM: IonFilipski
filipski@excite.com
 
Web Services typically run as hosted code in a process provided by a web server, that is what makes them Web Services. In ATL Server this is done in the form of a DLL exposing a specific interface. Although strictly speaking this model is not exclusive, but you will find most web servers supporting it natively. Should you desire to use an isolated process you might have to devise your own mechanism to integrate your process with a specific Web Server.

-pete
 
So, do I have to rewrite this game all over using some other language instead of Visual C++? What are your suggestions. Thanks
 
Ummm... ATL Server is exclusively C++. The project type produces a DLL that can be installed and executed under the IIS Web Server.

It is starting to appear that you do not have the prerequisite knowledge of internet application development and other related technologies to understand what we are saying. You should consider spending some time reading about the technologies to become acquainted with them conceptually before going any further with the project.

-pete
 
Check out ISAPI which stands for Internet Server API - and this will allow you to create your app as a DLL to be run as an IIS service on IIS servers. VC++ 6 has a project called ISAPI Extensions wizard that u can use -- in VS.NET I don't know if this exists but obviuosly microsoft has replaced most of their stuff with .NET technologies which are not that compatible with older servers and other non-microsoft servers.

U really need to use a web/server API for this b/c your application must accept/output http compatible stuff - and an API will help you with this - once you've done this you're 70% there - all u need to do is create the FLASH front end and get FLASH to extract the output from your program which is something im not sure how to implement in FLASH.

And that's it, u can use ATL/COM/ISAPI and maybe MFC can also help you just make your choice.


Rocco is the BOY!!

SHUT YOUR LIPS...
ROCCOsm.gif
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top