Sign in to follow this  

SDL_net and the very basics?

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

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