Guys there is another bug that has developed.........now messaged above 6 bytes are trimmed and echoed back to client.After the first message the echo is not regular.I have put a loop in both client and server to check for closing.Moreover for connection close i also need to put another clause that if there is a connection break in either server or client the connection should be closed from other side.Below are the server and clinet side codes after connection
Server
Code:
while(j!=0)
{
memset(buffer,0,1024);/*clear buffer*/
n = read(newsockfd,buffer,1024);/*read from client*/
if (n < 0) perror("\n ERROR reading from socket \n");/*check for errors*/
len=strlen(buffer);
for(i=0;i<=len;i++)
{
//strcpy(buf1,&buffer[i]);
//strcat(buf1,&buffer[i+1]);
k= strcmp("/",&buffer[i]);
if(k==0)
break;
break;
}
for(p=i;p<=len;p++)
{
j= strcmp("q",&buffer[p]);
if(j==0)
{
close(newsockfd);
close(sockfd);
exit(0);
}
}
puts(buffer);/*print message by client*/
write(newsockfd,"\n Client wrote",14);/*write to client*/
n=write(newsockfd,buffer,sizeof(buffer));/*write to client*/
if(n<0)perror("Write Failed");
}
Client Side
Code:
while(k!=0)
{
memset(&buf, 0, sizeof(buf));
printf("\n Enter Message for Server");
gets(buf);
rc = write(s, buf,sizeof(buf));
if(rc<0)
{
perror("write failed");
}
/* now that we are connected, start writing to the socket */
/* till write() returns 0, meaning the server closed */
/* the connection. */
len=strlen(buf);
for(i=0;i<=len;i++)
{
//strcpy(b1,&buf[i]);
//strcat(b1,&buf[i+1]);
l= strcmp("/",&buf[i]);
if(l==0)
break;
break;
}
for(p=i;p<=len;p++)
{
k= strcmp("q",&buf[p]);
if(k==0)
{
close(s);
exit (0);
}
}
read(s,buf1,14);
read(s,buf2,1024);
puts(buf1);/*print messages from server*/
puts(buf2);/*print messages from server*/
}
}
Last edited by reborg; 07-23-2007 at 09:03 AM..
Reason: code tags
hi,
i want to start developing an ios app that can be used on iphone and ipad. can anyone guide me how to start? i saw that it can be developed only on a mac system.. but i dont have a mac system. i have an ipad 4 and a laptop with windows os? can i use one of these to start developing ios app??... (4 Replies)
I need to rebuild an application that developed in unix environment and run in windows OS with cygwin. so How can I rebuild from the source code?
is there any one who said something on this regard? (2 Replies)
Hi friend,:)
The script should invoke these scripts sequentially!
When one will finish the second will start.
Please help me with it,
thanks,:b:
Ishai (3 Replies)
Discussion started by: ishai82
3 Replies
6. Post Here to Contact Site Administrators and Moderators
Can you please tell me how Gollum was created for a forum? I know of the ALICE and other bots but integrating the interface has always been my wish... Can someone give me some pointers on how to achieve this? (2 Replies)