We have made simple client.c
and server.c
programme in an UNIX environment. We are using it transfer a simple text file by first opening it, then reading it and sending using open
, read
, and send
system calls; on client side I am receiving it, and writing it by creating a file on server machine. The transfer is taking place quite smoothly but the file recieved at the client side is not exactly the same on the server side. In between the readable characters there are some unreadable characters. Can you please tell me what could be the possible reason for this? Though the most part of the file is same, only a small part in between has some discrepancies.
Code can be seen here.
Thanks!
server side loop:
do
{
n=read(t,buf,100);
write(1,buf,strlen(buf));
send(connected, buf,strlen(buf), 0);
} while(n!=0);
on client side
do
{
bytes_recieved=recv(sock,recv_data,100,0);
count=write(t,recv_data,strlen(recv_data));
} while(bytes_recieved!=0);