cross platform networking?
how should i go about doing this is there a libary out there that simplify's the process? or any other alternatives
I've just started using ENet, and I really like it. THere are plenty of options around, check the FAQ in the Alternative Libraries forum.
SDL_net
#include <SDL/SDL_net.h>#include <iostream>using namespace std;int main(){ if(SDLNet_Init()) { cerr << "error : SDLNet_Init()\t" << SDLNet_GetError() << "\n"; return -1; } IPaddress ip; SDLNet_ResolveHost(&ip,NULL,16); cout << "localhost = (" << SDLNet_ResolveIP(&ip) << ")\n"; SDLNet_ResolveHost(&ip,"www.gamedev.net",80); cout << "GDNet = (" << SDLNet_ResolveIP(&ip) << ")\n"; TCPsocket socket = SDLNet_TCP_Open(&ip); if(!socket) { cerr << "error : SDLNet_TCP_Open(&ip)\t" << SDLNet_GetError() << "\n"; } char *out = "hi\n"; if(SDLNet_TCP_Send(socket,out,4) < 4) { cerr << "error : SDLNet_TCP_Send(socket,out,4)\t" << SDLNet_GetError() << "\n"; } char in[128]; SDLNet_TCP_Recv(socket,(void*)in,128); in[127] = 0; cout << "GDNet reply [" << in << "]\n"; SDLNet_TCP_Close(socket); SDLNet_Quit(); return 0;}
What exactly do you want simplified? Plain old sockets works cross-platform with a minimum of helper #defines.
any tutorials out there for sockets programing? i was looking but most dont support windos only others ect... i am looking for windows linux and mac but if thats not possible i would like to at least get mac and windows
so i am gonna have to make a seperate windows version? and then use sockets for the other OS's?
Quote:Original post by Solance
so i am gonna have to make a seperate windows version? and then use sockets for the other OS's?
Sockets work just fine on Windows, Mac OS X, and *nix.
Read Beej's guide. It's the definitive intro to sockets.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement