Sign in to follow this  

cross platform networking?

This topic is 4675 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
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
What exactly do you want simplified? Plain old sockets works cross-platform with a minimum of helper #defines.

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
so i am gonna have to make a seperate windows version? and then use sockets for the other OS's?

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

This topic is 4675 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this