Jump to content
  • Advertisement
Sign in to follow this  
Solance

cross platform networking?

This topic is 5005 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

how should i go about doing this is there a libary out there that simplify's the process? or any other alternatives

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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;
}


Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!