cross platform networking?

Started by
7 comments, last by Solance 19 years ago
how should i go about doing this is there a libary out there that simplify's the process? or any other alternatives
Advertisement
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.
-Mike
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
Try the Forum FAQ.
enum Bool { True, False, FileNotFound };
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.
is there a link to a sample applications that was build off that tutorial and runs on windows because i must be following the directions incorrectly or something but i am doing what it says in Note to windows programmers.

This topic is closed to new replies.

Advertisement