Jump to content
  • Advertisement
Sign in to follow this  
Twixly

SDL_net and the very basics?

This topic is 4678 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

Hey I am trying to get SDL_net to work... sofar all I have managed is to send a single line of chat from the client and print it to the servers stdout it doesnt seem like I can manage to send more then once tho... Anyway, I was wondering if someone knows a good place to read about SDL_net ? I have seen 2 pages sofar and they havent helped alot. What I need is the basics, how to build a custom "data package" like a struct with locations x,y and player name.. and how to send that struct and recieve it on the server. if someone knows a place please let me know, or if you just wanna be helpfull "in realtime" I have msn : twixly_p@hotmail.com And I will be trying to get this working most of my weekend

Share this post


Link to post
Share on other sites
Advertisement
thats very funny. but its not really the issue :p




while (!quit)
{
if ((csd = SDLNet_TCP_Accept(sd)))
{


result = SDLNet_TCP_Recv(csd,msg,MAXLEN);
if(result <= 0) {
// TCP Connection is broken. (because of error or closure)
SDLNet_TCP_Close(csd);
exit(1);
}
else {
msg[result] = 0;
printf("Received: \"%s\"\n",msg);
}

if ((remoteIP = SDLNet_TCP_GetPeerAddress(csd))){
printf("User connected: %x %d\n", SDLNet_Read32(&remoteIP->host), SDLNet_Read16(&remoteIP->port));
user = SDLNet_ResolveIP(remoteIP);
printf("Host connected: %s\n", user.c_str());
}
else
fprintf(stderr, "SDLNet_TCP_GetPeerAddress: %s\n", SDLNet_GetError());

SDLNet_TCP_Close(csd);
}
}

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!