I just started working with a cool library called SDL_NET and am having some trouble. I am trying to connect to a server I made with it using my IP address. It says it connects, but the server doesn't send anything to the client like it should. This works fine when I use "localHost" as the servername. Please help?

server.cpp

#include <iostream>
#include <SDL.h>
#include <SDL_net.h>
#include <string.h>
#include <cstring>
#include <Windows.h>

const int MAX_SOCKETS=4;
const int MAX_CLIENTS=MAX_SOCKETS-1;

const int BUFFER_SIZE=4; //max number of characters able to be sent

using namespace std;

int main(int argc, char** argv)
{
//initialize SDL net and SDL
SDL_Init(SDL_INIT_EVERYTHING);
SDLNet_Init();

//get ip address, just a random number, NULL means it is a server not a client
IPaddress ip;
SDLNet_ResolveHost(&ip,NULL,1234);

Uint8 * dotQuad = (Uint8*)&ip.host;
cout << "Successfully resolved host to IP: " << (unsigned short)dotQuad[0] << "." << (unsigned short)dotQuad[1] << "." << (unsigned short)dotQuad[2] << "." << (unsigned short)dotQuad[3];
cout << " port " << SDLNet_Read16(&ip.port) << endl << endl;

//create our socket set
SDLNet_SocketSet socketset= SDLNet_AllocSocketSet(MAX_SOCKETS);


//creates server and add it to the socket set
TCPsocket server=SDLNet_TCP_Open(&ip);
SDLNet_TCP_AddSocket(socketset, server);



//ckient sockets along with whether or not they are free
TCPsocket client[MAX_CLIENTS];
bool freeclient[MAX_CLIENTS];

int clientcount=0;

bool serverrunning=true;

char buffer[BUFFER_SIZE];
int receivedbytecount=0;

//set all clients to free
for(int i=0;i<MAX_CLIENTS;i++)
{
client=NULL;
freeclient=true;
}

cout << "Hi, I'm a server!\nWoah! You're a user! Let's wait for others!" << endl;



while(serverrunning)
{

//check for activity on socket set with 0 as the wait time
int activesockets = SDLNet_CheckSockets(socketset,0);

if(activesockets != 0)
cout << "There are " << activesockets<< " others who want to see us! Isn't this exciting?" << endl;


//check if server has recieved data
int serveractivity = SDLNet_SocketReady(server);

if(serveractivity != 0)
{
if(clientcount < MAX_CLIENTS) // if more room for clients
{
//find first free socket
int freespot = -99;
for(int i=0; i<MAX_CLIENTS; i++)
{
if(freeclient)
{
freeclient=false;
freespot=i;
break;
}
}

//accept client connection and add it to socket set
client[freespot] = SDLNet_TCP_Accept(server);
SDLNet_TCP_AddSocket(socketset,client[freespot]);

clientcount++;

strcpy(buffer,"OK");
SDLNet_TCP_Send(client[freespot], (void *)buffer,strlen(buffer)+1);
strcpy(buffer,"");
cout << "Someone is here! " << "Now there are " << clientcount<< " people here!" << endl;
}

else //if we don't have anymore room
{
cout << "Some idiot is trying to enter when we are already filled up!" << endl;

//accept them temporarily just to tell them to GTFO
TCPsocket tempsock = SDLNet_TCP_Accept(server);

strcpy(buffer,"Get out of here!");
SDLNet_TCP_Send(tempsock, (void *)buffer, strlen(buffer)+1);

SDLNet_TCP_Close(tempsock);
}
}// end of checking server activity

//see if clients have any activity
for(int i=0; i<MAX_CLIENTS; i++)
{
int clientactivity = SDLNet_SocketReady(client);

//if any activity
if(clientactivity!=0)
{
strcpy(buffer,"");
cout << buffer<< endl;
receivedbytecount = SDLNet_TCP_Recv(client,buffer, BUFFER_SIZE);


//check if they disconnected
if(receivedbytecount<=0)
{
cout << "Client " << i << " has left! What a jerk!" << endl;

//remove socket from socket set and reset it
SDLNet_TCP_DelSocket(socketset,client);
SDLNet_TCP_Close(client);
client = NULL;
freeclient = true;
clientcount--;
cout << "Now there is only " << clientcount << " people here ;_;" << endl;
}

//if they actually sent something worth our time
else
{
cout << "We received a message!" << endl;

cout << "Message says " << buffer << endl;

int origin = i;

for(int n=0; n<MAX_CLIENTS; n++)
{
if (strlen(buffer)+1 > 1 && n!=origin && freeclient[n]==false)
{
cout << "transmitting " << buffer << endl;
SDLNet_TCP_Send(client[n], (void*)buffer,strlen(buffer));
}
}
}
}// end of checking clients
} // end of server checking

}

strcpy(buffer,"/shutdown");
for(int n=0; n<MAX_CLIENTS; n++)
{
cout << "transmitting " << buffer << endl;
SDLNet_TCP_Send(client[n], (void*)buffer,strlen(buffer));
}

SDLNet_FreeSocketSet(socketset);

//close server socket
SDLNet_TCP_Close(server);

SDLNet_Quit();
SDL_Quit();

return 1;
}



client.cpp

#include <iostream>
#include <SDL.h>
#include <SDL_net.h>
#include <string.h>
#include <sstream>
#include <cstring>
#include <cstdlib>
#include <Windows.h>
#include <conio.h>


using namespace std;

const int BUFFER_SIZE=516;

void openfile(string filename);


int main(int argc, char** argv)
{
//initialize SDL net and SDL
SDL_Init(SDL_INIT_EVERYTHING);
SDLNet_Init();




//get ip address, just a random number, NULL means it is a server not a client
IPaddress ip;



string servername="174.60.157.213"; //my IP
string userinput="";
int inputlength=0;
char buffer[BUFFER_SIZE];
bool killclient=true;

cout << "Server Name: ";
cout << servername.c_str() << endl;

//create socket set
SDLNet_SocketSet socketset = SDLNet_AllocSocketSet(1);

SDLNet_ResolveHost(&ip,servername.c_str(),1234);

Uint8 * dotQuad = (Uint8*)&ip.host;
cout << "Successfully resolved host to IP: " << (unsigned short)dotQuad[0] << "." << (unsigned short)dotQuad[1] << "." << (unsigned short)dotQuad[2] << "." << (unsigned short)dotQuad[3];
cout << " port " << SDLNet_Read16(&ip.port) << endl << endl;


//creates client socket
TCPsocket client=SDLNet_TCP_Open(&ip);

/*if(!client)
{
cout<<"opening server"<<endl;
openfile("SDL_NET.exe");
client = SDLNet_TCP_Open(&ip);
}*/

cout << "Hurray for connection!" << endl;

SDLNet_TCP_AddSocket(socketset,client);

//check for server response (we wait 5 seconds here)
int activesockets = SDLNet_CheckSockets(socketset,5000);

int gotresponse = SDLNet_SocketReady(client);

if(gotresponse!=0)
{
cout << "We got a response sir!" << endl;
int serverbytecount = SDLNet_TCP_Recv(client,buffer, BUFFER_SIZE);
string received = buffer;
if(received.length() > serverbytecount)
{
received.erase(serverbytecount);
}

cout<< "Server said: " << received.c_str() << endl;

if( strcmp(received.c_str(),"OK") == 0)
{
killclient=false;

cout << "Joining the server!" << endl;
strcpy(buffer,"");
}
else
cout << "Server is full. Let's go home." << endl;
}
else
cout << "No response (twilight zone music)" << endl;
// end of server connection creation

bool wroteprompt=false;
bool sendmessage=false;

while(!killclient)
{

if(kbhit())
{
char theChar = getch();
cout<<theChar;
fflush(stdout);

if((int)theChar != 13)
{
userinput += theChar;

}
else
{
strcpy(buffer,userinput.c_str());
SDLNet_TCP_Send(client, (void*)buffer,strlen(buffer)+1);


if (sendmessage == true && (userinput.c_str() == "/quit"))
{
killclient=true;
}
wroteprompt=false;

cout<<buffer<<endl;
userinput="";

}
}

if(wroteprompt == false)
{
cout << "Message: " << endl;
wroteprompt=true;
}


int socketactive = SDLNet_CheckSockets(socketset,0);

if (socketactive != 0)
{
//see if we got response from server
int response = SDLNet_SocketReady(client);

if(response !=0)
{

strcpy(buffer,"");
int responsebytes = SDLNet_TCP_Recv(client, buffer, BUFFER_SIZE);
string received = buffer;
if(received.length() > responsebytes)
{
received.erase(responsebytes);
}
cout << "Received: " << received.c_str() << endl;

if(responsebytes<=0)
{
cout << "Sir, the server has been hit! We're going down!" << endl;
cout << "Press ENTER to continue..." << endl;
cin.get();
killclient=true;
}

if(strcmp(buffer, "/shutdown")==0)
{
cout << "Sir, the server has been hit! We're going down!" << endl;
cout << "Press ENTER to continue..." << endl;
cin.get();
killclient=true;
}
strcpy(buffer,"");
}
}

}

//close client socket
SDLNet_TCP_Close(client);


SDLNet_Quit();
SDL_Quit();

return 1;
}

void openfile(string filename)
{
float i=0;
ShellExecute(NULL,"open",filename.c_str(),NULL,NULL,SW_SHOWNORMAL);
while(i<1000)
{
cout<< "starting server in " <<(float)i/10<<endl;
i+=1;
}

cout<<endl;
}



You have to compile these separately for it to work. Change the servername variable in client.cpp to your IP and run the server program. Then run the client program to see if it works.

I appreciate the help! Thanks!