sorry for the previous message, i was reading what you said again and again and i think you meant that i need to close the socket instead of giving it a zero value.
with this changed code the problem remains :
int main(int argc, char **argv)
{
int len = 0;
char text[20];
char msg[1024];
int mousexbefore = 0;
int mouseybefore = 0;
bool needtojoin = 0;
char needtojoinip[50];
Uint16 port;
pressed = 0;
mousex = 0;
mousey = 0;
IPaddress hostip, serverip, *somecomputerip;
TCPsocket listeningsocket, joiningsocket, somecomputer;
bool close = 0;
printf(“joining. plz wait\n”);
needtojoin = 1;
printf(“write the IP Address you want to join to :\n”);
scanf("%s", needtojoinip);
printf(“write the port you want to use : \n”);
scanf("%d", &port);
internetinit();
setupsocket(&hostip, NULL, port);
listeningsocket = openTCP(&hostip);
char mychar = 3;
msg[0] = ‘0’;
msg[1] = 0;
setupsocket(&serverip, needtojoinip, port);
joiningsocket = openTCP(&serverip);
senddataTCP(joiningsocket, msg);
while (!(somecomputer = SDLNet_TCP_Accept(listeningsocket)));
while(SDLNet_TCP_Recv(somecomputer,&mychar,1)==1 && mychar!=0)
{
if (mychar == ‘0’)
printf(“recieved message\n”);
}
mychar = 3;
cleanstring(msg);
msg[0] = ‘0’;
msg[1] = 0;
senddataTCP(somecomputer, msg);
SDLNet_TCP_Close(somecomputer);
while (!(somecomputer = SDLNet_TCP_Accept(listeningsocket)));
while(SDLNet_TCP_Recv(somecomputer,&mychar,1)==1 && mychar!=0)
{
if (mychar == ‘0’)
printf(“recieved second message\n”);
}
scanf("%s", &text);
SDLNet_Quit();
SDL_Quit();
exit(0);
}
void internetinit(void)
{
if(SDLNet_Init()==-1)
{
printf(“SDLNet_Init: %s\n”,SDLNet_GetError());
}
}
void setupsocket(IPaddress *address, char *ipinstring, Uint16 port)
{
if(SDLNet_ResolveHost(address,ipinstring,port)==-1)
{
printf(“SDLNet_ResolveHost: %s\n”,SDLNet_GetError());
}
}
TCPsocket openTCP(IPaddress *ip)
{
TCPsocket socket;
socket = SDLNet_TCP_Open(ip);
if(!socket)
{
printf(“SDLNet_TCP_Open: %s\n”,SDLNet_GetError());
}
return socket;
}
void senddataTCP(TCPsocket socket, char *msg)
{
int len,result;
len=strlen(msg)+1; // add one for the terminating NULL
result=SDLNet_TCP_Send(socket,msg,len);
if(result<len)
{
printf(“SDLNet_TCP_Send: %s\n”, SDLNet_GetError());
// It may be good to disconnect sock because it is likely invalid now.
}
}
void translateip(IPaddress ipnativeform , char *ipstring)
{
Uint32 ipaddr;
ipaddr=SDL_SwapBE32(ipnativeform.host);
char one[6];
char two[6];
char three[6];
char four[6];
sprintf(ipstring, “%d.%d.%d.%d”, ipaddr>>24, (ipaddr>>16)&0xff, (ipaddr>>8)&0xff,ipaddr&0xff);
}____________________________________________________________________________________
Now that’s room service! Choose from over 150,000 hotels
in 45,000 destinations on Yahoo! Travel to find your fit.
http://farechase.yahoo.com/promo-generic-14795097