C++ Networking

Started by
4 comments, last by codeking 16 years, 10 months ago
i was looking at the gpwiki SDL networking tutorial. (http://gpwiki.org/index.php/SDL:Tutorial:Using_SDL_net) i was just wonder how the client resolved the ip and the port of the server?
Take it easy,CodeKing
Advertisement
Normally the host port and ip are known to a client unless there is a game lobby, but even then the lobby is known. From a quick look :
Quote:

/* Resolve the host we are connecting to */
if (SDLNet_ResolveHost(&ip, argv[1], atoi(argv[2])) < 0)

The client is getting the information from the command line.
so in a game lobby i would have the client connect to my websites server

then that brings up two questions. how do i find out the ip address of the computer the program is running on. and how would i program my linux server to open the lobby socket? im experienced with PHP, and i know how to use sockets with it, but how would i keep it connected to the socket 24/7?
Take it easy,CodeKing
I think your questions would be better being posted in the network forum, but anyway.
Quote:
how do i find out the ip address of the computer the program is running on.
Do you mean the server? for server it would be an hard coded port and possibly a web addy.
Quote:
how would i program my linux server to open the lobby socket

Just using BSD and connecting to.
Quote:... but how would i keep it connected to the socket 24/7
which do you mean the server or client?
i dont think my hosting company would appreciate my socket program running 24/7, its a shared server after all. but i thought up an idea to have (almost) serverless lobby. i only have one question, is there any way to read and write to a database on my server using C++?
Take it easy,CodeKing
or i could write a PHP script to edit the database, but how would you request that webpage. (Using C++, obviously)
Take it easy,CodeKing

This topic is closed to new replies.

Advertisement