#include "netinet/in.h"
#include "unistd.h"
#include "stdio.h"
#include "sys/types.h"
#include "sys/socket.h"
#include "stdlib.h"
#include "arpa/inet.h"
#define IP "127.0.0.1"
#define PORT 6010
int main()
{
int sd,ad,bd,i=0,j,ss;
char fn[256],buf[5000],c;
FILE *fp;
struct sockaddr_in server,client;
if((sd=socket(AF_INET,SOCK_STREAM,0))<0)
printf("\nSocket Error");
server.sin_addr.s_addr=inet_addr(IP);
server.sin_port=htons(PORT);
server.sin_family=AF_INET;
if((bd=bind(sd,(struct sockaddr *)&server,sizeof(server)))<0)
printf("\nBind Error");
listen(sd,5);
ss=sizeof(client);
if((ad=accept(sd,(struct sockaddr *)&client,&ss))<0)
printf("\nAccept Error");
read(ad,&fn,sizeof(fn));
fp=fopen(fn,"r");
if(fp==NULL)
{
printf("\nFile doesnot exist");
write(ad,&i,sizeof(i));
exit(0);
}
while((c=fgetc(fp))!=EOF)
{
buf[i]=c;
i++;
}
write(ad,&i,sizeof(i));
for(j=0;j
write(ad,&buf[j],sizeof(buf[j]));
fclose(fp);
close(sd);
close(bd);
close(ad);
return 0;
}
This entry was posted
at 4:54 AM
and is filed under
Networks-programs
. You can follow any responses to this entry through the
comments feed
.
Reverse Engineering :Subscribe Now
Zts - ZTS
DISCLAIMER
This Blog is ONLY for educational purposes,
and any such codes/snippets provided are to be executed on
your sole discretion. The author is not responsible for the codes.
and any such codes/snippets provided are to be executed on
your sole discretion. The author is not responsible for the codes.
Categories
- Amazing Links (2)
- Ebooks (2)
- Games (1)
- Hacking (49)
- Hardware (2)
- Networks-programs (12)
- virus (4)
- Web Info (4)
- Xp-Tricks (19)
Subscribe Now
Page Hits
Provided by website design company directory. |