1234567891011121314151617181920212223242526272829 |
- #include<stdio.h>
- #include<unistd.h>
- #include<sys/socket.h>
- #include<sys/types.h>
- #include<netinet/in.h>
- #include<string.h>
- #include<stdlib.h>
- int main()
- {
- int sd,port;
- char msg[80];
- struct sockaddr_in cli;
- sd=socket(AF_INET,SOCK_STREAM,0);
- bzero(&cli,sizeof(cli));
- printf("enter the port no");
- scanf("%d",&port);
- cli.sin_port=port;
- cli.sin_addr.s_addr=inet_addr("127.0.0.1");
- cli.sin_family=AF_INET;
- connect(sd,(struct sockaddr*)&cli,sizeof(cli));
- printf("\nenter the command\n");
- scanf("%s",msg);
- write(sd,msg,strlen(msg));
- system(msg);
- read(sd,msg,10);
- printf("%s",msg);
- return 0;
- }
|