More SDL troubles

Hi again,

I’ve gotten farther with my netlib based code. I can now send out a
message from the server, and have the client receive it and send a
response back and have the server receive it. The problem is when I try
to send out another message from the server, it never makes it to the
client.

Here’s my code

/* client code */

void clientConnect(void) /* Code to create a connection to specified
server */
{
SDLNet_ResolveHost(&clients.serverIP,clients.hostname,5555);
printf (“server: %s \n”, clients.hostname);
clients.tcpsock = SDLNet_TCP_Open(&clients.serverIP);

}

void clientSend(void) /* Code which sends data to server via a socket
*/
{
strncat(clients.data2,“Ultimate Basketball Challenge client release
0.4.0”,4096);
SDLNet_TCP_Send(clients.tcpsock,clients.data2,strlen(clients.data2));
printf (“data2 after send = %s \n”, clients.data2);

}

void clientReceive(void) /* Code which receives data from a server via
a socket */
{

printf ("receive returns = %d \n",

SDLNet_TCP_Recv(clients.tcpsock,clients.data,4096));
printf (“data = %s \n”,clients.data);
}

void clientReceiveNumber(void)
{
char client[2];

printf ("receive returns = %d

\n",SDLNet_TCP_Recv(clients.newsock,client,2));
printf (“client number = %s \n”,client);
}

/* server code */

void serverStart(void) /* Starts sockets code for server */
{
char client[2];
char *clientname = client;

server.servsock = NULL;
SDLNet_ResolveHost(&server.serverIP, NULL, 5555);
server.servsock = SDLNet_TCP_Open(&server.serverIP);
server.newsock = SDLNet_TCP_Accept(server.servsock);

}

void serverSendData(void)
{
strcat(server.data,“Ultimate Basketball Challenge server release
0.4.0”);

SDLNet_TCP_Send(server.newsock,server.data,strlen(server.data));
printf("data 2 before = %s \n", server.data2);

}

void serverGetData(void)
{
char client[2];
char *clientname = client;
// int clients;
// server.newsock = SDLNet_TCP_Accept(server.servsock);

printf ("recieve returns =

%d\n",SDLNet_TCP_Recv(server.newsock,server.data2,4096));
printf(“data 2 after = %s \n”, server.data2);
// SDLNet_TCP_Close(server.newsock);
//exit(1);
if (server.clientCount == 0)
{
server.servsock = NULL;
// server.secsock= SDLNet_TCP_Accept(server.servsock);
server.clientCount = 1;
strcpy(client,“1”);
printf(“clientNumber = %s \n”,clientname);

	SDLNet_TCP_Send(server.newsock,client,strlen(client));
	//SDLNet_TCP_Send(server.secsock,clientname,strlen(clientname));
	exit(1);		
}	

}

Any help is greatly appreciated, sorry if it’s something stupid I’ve
overlooked. I’ve been running it through DDD for the last few hours
with no luck :frowning:

Mike