Monday, 25 February 2019
Tuesday, 19 February 2019
SSC JE 2019 Mechanical Engineering Paper II Syllabus in Hindi and English
rlmdtechnical February 19, 2019 SSC JE recruitment 2019 preparation No comments
The syllabus of Mechanical engineering for SSC JE recruitment 2019 topic wise in Hindi and English both .The application for ssc je are invited for the eligible candidate from 28/01/2019 to 25/02/2019 the paper I exam will be in September 2019 and the paper second exam will be in December 2019 .The syllabus for paper second for Mechanical
Download SSC JE 2019 Mechanical Engineering Paper II Syllabus in Hindi and English
Do not forget to subscribe me for latest update on my blog , follow me and grow your knowledge. thank you
SSC JE 2019 Electrical Engineering Paper II Syllabus in Hindi and English
rlmdtechnical February 19, 2019 SSC JE recruitment 2019 preparation No comments
DOWNLOAD SSC JE 2019 ELECTRICAL ENGINEERING SYLABUS PAPER II
Do not forget to subscribe me for latest update on my blog , follow me and grow your knowledge. thank you.
Monday, 18 February 2019
SSC JE 2019 Civil Engineering Paper II Syllabus in Hindi and English
rlmdtechnical February 18, 2019 SSC JE recruitment 2019 preparation No comments
Do not forget to subscribe me for latest update on my blog , follow me and grow your knowledge. thank you.
SSC JE 2019 new syllabus in Hindi and English paper I and second II both
rlmdtechnical February 18, 2019 SSC JE recruitment 2019 preparation No comments
जनरल इंटेलिजेंस एंड रीजनिंग: (General Intelligence & Reasoning:)
सामान्य जागरूकता: (General Awareness)
Do not forget to subscribe me for latest update on my blog , follow me and grow your knowledge. thank you.
Saturday, 16 February 2019
Dummy Client-Server TCP Socket Program in c
rlmdtechnical February 16, 2019 socket programming in c No comments
b) if server is started successfully Then the second step is to start client (server IP and port are provided on the command line).
c) The client connects to the server, and then asks the user for input.(e.g., "Hi", "Bye", "How are you").
d) The server reads the user's input from the client socket. If the server gets "Bye" (without the quotes), the server must reply with "Goodbye". For any other, the server must reply "OK".
e) The client then reads the reply from the server, and checks that it is accurate (either "OK" or "Goodbye").
f) If the user had typed "Bye", and the server replied with a "Goodbye" correctly, the client quits. Otherwise, the client asks the user for the next message to send to the server. If the server sends a wrong reply, say, "NO" instead of "OK", the client exits with error message.
dummyServer.c
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<unistd.h>
#include<sys/types.h>
#include<sys/socket.h>
#include<netinet/in.h>
#include<netdb.h>
#include<arpa/inet.h>
#include<time.h>
#define MAX_SIZE 1024
#define PORT 8888
int main(int argc,char *argv[])
{
int sockfd;
socklen_t len;
pid_t childpid;
unsigned short servport;
char sbuffer[100];
char rbuffer[100];
int *new;
servport = atoi(argv[1]);
struct sockaddr_in serveraddr,clientaddr;
sockfd=socket(PF_INET,SOCK_STREAM,0);
memset(&serveraddr,'\0',sizeof(serveraddr));
serveraddr.sin_family=PF_INET;
serveraddr.sin_port=htons(servport);
serveraddr.sin_addr.s_addr=INADDR_ANY;
bind(sockfd,(struct sockaddr*)&serveraddr,sizeof(serveraddr));
listen(sockfd,5);
printf("binding done waiting for client\n");
while(1){
len=sizeof(clientaddr);
int newsockfd=accept(sockfd,(struct sockaddr*)&clientaddr,&len);
if(newsockfd<0){
exit(1);
}
printf("Connected to....");
printf("client ip = %s\nand client port = %d\n",inet_ntoa(clientaddr.sin_addr),ntohs(clientaddr.sin_port));
if((childpid = fork()) == 0){
close(sockfd);
while(1)
{
memset(rbuffer,'\0',sizeof(rbuffer));
recv(newsockfd,rbuffer,MAX_SIZE,0);
printf("Client Message.....%s\n",rbuffer);
if(strcmp(rbuffer,":exit") == 0){
printf("Disconnected from...%s:%d\n",inet_ntoa(clientaddr.sin_addr), ntohs(clientaddr.sin_port));
break;
}
else if(strcmp(rbuffer,"Bye") == 0)
{
strcpy(sbuffer,"GoodBye");
send(newsockfd,sbuffer,strlen(sbuffer),0);
//memset(&sbuffer,'\0',sizeof(sbuffer));
close(sockfd);
}
else{
//memset(&rbuffer,'\0',sizeof(rbuffer));
strcpy(sbuffer,"OK");
send(newsockfd,sbuffer,strlen(sbuffer),0);
close(sockfd);
}
}
}
}
return 0;
}
TCPClient.c
note :- Run dummy Server first with a known port number provided to command line and then run TCPClient program with providing the server port number and server ip.As given bellow in the screen shot.#include<stdio.h>
#include<stdlib.h>
#include<sys/types.h>
#include<sys/socket.h>
#include<unistd.h>
#include<arpa/inet.h>
#include<netdb.h>
#include<string.h>
#define MAXSIZE 1024
int main(int argc,char **argv)
{
int sockfd,length;
char sbuffer[100];
char rbuffer[100];
unsigned short servport;
char* servip;
struct sockaddr_in serveraddr;
servport = atoi(argv[1]);
servip = argv[2];
sockfd=socket(PF_INET,SOCK_STREAM,0);
memset(&serveraddr,'\0',sizeof(serveraddr));
serveraddr.sin_family=PF_INET;
serveraddr.sin_port=htons(servport);
serveraddr.sin_addr.s_addr=inet_addr(servip);
while(1){
connect(sockfd,(struct sockaddr*)&serveraddr,sizeof(serveraddr));
printf("Enter message... \n");
scanf("%s",sbuffer);
send(sockfd,sbuffer,strlen(sbuffer),0);
memset(rbuffer,'\0',sizeof(rbuffer));
recv(sockfd,rbuffer,MAXSIZE,0);
printf("Message from server....%s\n",rbuffer);
if((strcmp(rbuffer,"GoodBye")) == 0)
break;
else{
printf("Enter message... \n");
scanf("%s",sbuffer);
send(sockfd,sbuffer,strlen(sbuffer),0);
recv(sockfd,rbuffer,MAXSIZE,0);
}
memset(sbuffer,'\0',sizeof(sbuffer));
}
return 0;
}
Do not forget to subscribe me for latest update on my blog , follow me and grow your knowledge. thank you.
Tuesday, 12 February 2019
Random String Generating TCP Socket in c
rlmdtechnical February 12, 2019 socket programming in c No comments
b) The server then sends a line of text to the client containing a random number of characters.
c) The client sends back a number equal to the number of characters in the line of text and closes its end of the connection. So if the server sent 132 bytes of text, the client would send ``132''.
The server sends back a response indicating whether the client's input was correct
server.c
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<unistd.h>
#include<sys/types.h>
#include<sys/socket.h>
#include<netinet/in.h>
#include<netdb.h>
#include<arpa/inet.h>
#include<time.h>
#define MAX_SIZE 5000
#define PORT 8888
char *randstring(size_t length) {
static char charset[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789,.-#'?!";
char *randomString = NULL;
if (length) {
randomString = malloc(sizeof(char) * (length +1));
if (randomString) {
for (int n = 0;n < length;n++) {
int key = rand() % (int)(sizeof(charset) -1);
randomString[n] = charset[key];
}
randomString[length] = '\0';
}
}
return randomString;
}
int main(int argc,char *argv[])
{
int sockfd;
socklen_t len;
unsigned short servport;
char sbuffer[5000];
char rbuffer[100];
int *new;
servport = atoi(argv[1]);
struct sockaddr_in serveraddr,clientaddr;
sockfd=socket(PF_INET,SOCK_STREAM,0);
memset(&serveraddr,'\0',sizeof(serveraddr));
serveraddr.sin_family=PF_INET;
serveraddr.sin_port=htons(servport);
serveraddr.sin_addr.s_addr=INADDR_ANY;
bind(sockfd,(struct sockaddr*)&serveraddr,sizeof(serveraddr));
listen(sockfd,5);
while(1){
len=sizeof(clientaddr);
int newsockfd=accept(sockfd,(struct sockaddr*)&clientaddr,&len);
printf("Connected to....");
printf("client ip = %s\nand client port = %d\n",inet_ntoa(clientaddr.sin_addr),ntohs(clientaddr.sin_port));
char *s;
int num;
srand(time(0));
for(int i=0;i<1;i++){
num = rand()%50 + 500;
}
s= randstring(num);
puts(s);
strcpy(sbuffer,s);
send(newsockfd,sbuffer,strlen(sbuffer),0);
recv(newsockfd,rbuffer,MAX_SIZE,0);
printf(" value received from client = %d\n",atoi(rbuffer));
if(strlen(sbuffer) == atoi(rbuffer))
{
strcpy(sbuffer,"correct");
send(newsockfd,sbuffer,strlen(sbuffer),0);
}
else
{
strcpy(sbuffer,"NO");
send(newsockfd,sbuffer,strlen(sbuffer),0);
}
}
return 0;
}
client.c
#include<stdio.h>
#include<stdlib.h>
#include<sys/types.h>
#include<sys/socket.h>
#include<unistd.h>
#include<arpa/inet.h>
#include<netdb.h>
#include<string.h>
#define MAXSIZE 6000
int main(int argc,char **argv)
{
int sockfd,length;
char sbuffer[5000];
char rbuffer[100];
unsigned short servport;
char* servip;
struct sockaddr_in serveraddr;
servport = atoi(argv[1]);
servip = argv[2];
sockfd=socket(PF_INET,SOCK_STREAM,0);
memset(&serveraddr,'\0',sizeof(serveraddr));
serveraddr.sin_family=PF_INET;
serveraddr.sin_port=htons(servport);
serveraddr.sin_addr.s_addr=inet_addr(servip);
connect(sockfd,(struct sockaddr*)&serveraddr,sizeof(serveraddr));
recv(sockfd,sbuffer,MAXSIZE,0);
printf("\n\nMessage from server side....%s\n",sbuffer);
length = strlen(sbuffer);
sprintf(rbuffer,"%d",length);
send(sockfd,rbuffer,strlen(rbuffer),0);
int num = atoi(rbuffer);
printf("send value is %d\n",num);
memset(sbuffer,'\0',sizeof(sbuffer));
recv(sockfd,sbuffer,MAXSIZE,0);
printf("\n\nMessage from server side....%s\n",sbuffer);
return 0;
}
note : open your terminal and run server program first by providing a port no. greater than 1024 and then run client by providing the server ip and port no. as given bellow in the screen-shot .
Saturday, 9 February 2019
Calculating Server using TCP Sockets
rlmdtechnical February 09, 2019 socket programming in c No comments
The following programs run on different terminal with a unique IP address and port number after success full initiation of server and client programs the user enter the number and operator on the client port and send to the server then server calculate the number with entered operator and send the result to the client.
calcclient.c
#include<stdio.h>
#include<string.h>
#include<sys/socket.h>
#include<arpa/inet.h>
#include<unistd.h>
#include<ctype.h>
#include<stdlib.h>
#include<netinet/in.h>
#define BUF_SIZE 1000
int main(int argc , char *argv[])
{
int sockfd ,n;
char sbuffer[BUF_SIZE], rbuffer[BUF_SIZE];
unsigned int servport;
char* servip;
char x[100],y[100],z[100];
servport = atoi(argv[1]);
servip = argv[2];
struct sockaddr_in serveraddress;
sockfd = socket(PF_INET,SOCK_STREAM,0);
serveraddress.sin_port = htons(servport);
serveraddress.sin_family = PF_INET;
serveraddress.sin_addr.s_addr = inet_addr(servip);
while(1)
{
int con = connect(sockfd,(struct sockaddr *) &serveraddress,sizeof(serveraddress));
do{
printf("Enter 1st number : ");
scanf("%s", sbuffer);
send(sockfd, sbuffer, strlen(sbuffer) + 1, 0);
printf("data sent (%s)\n", sbuffer);
printf("Enter 2nd number : ");
scanf("%s", sbuffer);
send(sockfd, sbuffer, strlen(sbuffer) + 1, 0);
printf("data sent (%s)\n", sbuffer);
printf("Enter :1 for + , 2 for -, 3 for *, 4 for / ");
scanf("%s", sbuffer);
send(sockfd, sbuffer, strlen(sbuffer) + 1, 0);
printf("data sent (%s)\n", sbuffer);
n=recv(sockfd, sbuffer, BUF_SIZE, 0);
printf("received from server %s\n", sbuffer);
}while(strcmp(sbuffer, "quit"));
}
return 0;
}
calcserver.c
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<netinet/in.h>
#include<arpa/inet.h>
#include<sys/socket.h>
#include<unistd.h>
#include<ctype.h>
#define MAX_SIZE 1000
char* stringReverse(char *str){
char ch;
char first[100];
int length=strlen(str);
for(int i=0;i<length;i++)
{
ch=str[i];
if(ch == '+'||'*'||'/'||'-')
{
printf("%s is in the position of %d\n",&ch,i);
}
str[i]=str[--length];
str[length]=ch;
}
return str;
}
int main(int argc , char *argv[])
{
int serversocket,clientsocket;
char sbuffer[MAX_SIZE],rbuffer[MAX_SIZE];
unsigned int clientaddrlen;
unsigned short serverport;
int opr;
int n,num1,num2,num3,sum = 0;
serverport = atoi(argv[1]);
struct sockaddr_in serveraddress,clientaddress;
serversocket = socket(PF_INET,SOCK_STREAM,0);
serveraddress.sin_family = PF_INET;
serveraddress.sin_port = htons(serverport);
serveraddress.sin_addr.s_addr = INADDR_ANY;
bind(serversocket,(struct sockaddr *) &serveraddress,sizeof(serveraddress));
listen(serversocket,5);
printf("binding done waiting for client .....\n");
while(1)
{
clientaddrlen = sizeof(clientaddress);
clientsocket = accept(serversocket,(struct sockaddr *)&clientaddress,&clientaddrlen);
printf("connected to the client ip = %s\nand portnumber = %d\n",inet_ntoa(clientaddress.sin_addr),ntohs(clientaddress.sin_port));
do{
memset(rbuffer,0x0,MAX_SIZE);
n=recv(clientsocket, rbuffer, MAX_SIZE, 0);
num1=atoi(rbuffer);
printf("recieved first number (%d)\n",num1);
n=recv(clientsocket, rbuffer, MAX_SIZE, 0);
num2=atoi(rbuffer);
printf("recieved second number (%d)\n",num2);
n=recv(clientsocket, rbuffer, MAX_SIZE, 0);
opr=atoi(rbuffer);
printf("recieved operator (%d)\n",opr);
switch(opr)
{
case 1:
sum = num1+num2;
break;
case 2:
sum = num1-num2;
break;
case 3:
sum = num1*num2;
break;
case 4:
sum = num1/num2;
break;
default:
break;
}
sprintf(sbuffer,"%d",sum);
send(clientsocket, sbuffer, strlen(sbuffer) + 1, 0);
printf("send number (%d)\n",sum);
}while(abs(strcmp(rbuffer, "quit")));
}
close(serversocket);
return 0;
}
output:
Other questions in of socket programming using c
String Reversal Server using TCP Sockets
rlmdtechnical February 09, 2019 socket programming in c 1 comment
Question :
revserver.c
#include<stdio.h>
#include<ctype.h>
#include <netinet/in.h>
#include<stdlib.h>
#include<string.h>
#include<arpa/inet.h>
#include<sys/socket.h>
#include<unistd.h>
#define BUF_SIZE 1000
char* stringReverse(char *str){
char ch;
int length=strlen(str);
for(int i=0;i<length/2;i++)
{
ch=str[i];
str[i]=str[--length];
str[length]=ch;
}
return str;
}
int main(int argc , char *argv[])
{
char sbuffer[BUF_SIZE],rbuffer[BUF_SIZE];
unsigned int len;
int sockfd , newsockfd;
unsigned short servport;
servport = atoi(argv[1]);
struct sockaddr_in serveraddress , clientaddress;
sockfd = socket(PF_INET , SOCK_STREAM,0);
serveraddress.sin_family = PF_INET;
serveraddress.sin_port = htons(servport);
serveraddress.sin_addr.s_addr = INADDR_ANY;
bind(sockfd,(struct sockaddr *)&serveraddress,sizeof(serveraddress));
listen(sockfd,5);
printf("binding done Waiting for client:......\n");
while(1)
{
len = sizeof(clientaddress);
newsockfd = accept(sockfd , (struct sockaddr *) &clientaddress , &len);
printf("connected to the client IP = %s \n and port number = %d\n",inet_ntoa(clientaddress.sin_addr),ntohs(clientaddress.sin_port));
while(newsockfd)
{
recv(newsockfd,rbuffer,BUF_SIZE,0);
printf("client message = %s\n",rbuffer);
char *ptr = stringReverse(rbuffer);
strcpy(sbuffer , ptr);
send(newsockfd,sbuffer,strlen(sbuffer),0);
printf("send message = %s\n",sbuffer);
memset(rbuffer,'\0',strlen(sbuffer));
memset(sbuffer,'\0',strlen(rbuffer));
}
}
return 0;
}
revclient.c
#include<stdio.h>
#include<string.h>
#include<sys/socket.h>
#include<arpa/inet.h>
#include<unistd.h>
#include<ctype.h>
#include<stdlib.h>
#include<netinet/in.h>
#define BUF_SIZE 1000
int main(int argc , char *argv[])
{
int sockfd;
char sbuffer[BUF_SIZE], rbuffer[BUF_SIZE];
unsigned int servport;
char* servip;
servport = atoi(argv[1]);
servip = argv[2];
struct sockaddr_in serveraddress;
sockfd = socket(PF_INET,SOCK_STREAM,0);
serveraddress.sin_port = htons(servport);
serveraddress.sin_family = PF_INET;
serveraddress.sin_addr.s_addr = inet_addr(servip);
while(1)
{
int con = connect(sockfd,(struct sockaddr *) &serveraddress,sizeof(serveraddress));
printf("Enter string....\n");
scanf("%s",sbuffer);
if(sbuffer)
{
send(sockfd,sbuffer,strlen(sbuffer),0);
printf("send message = %s\n",sbuffer);
recv(sockfd,rbuffer,BUF_SIZE,0);
printf("server message = %s\n",rbuffer);
memset(rbuffer,'\0',strlen(rbuffer));
memset(sbuffer,'\0',strlen(sbuffer));
}
}
return 0;
}output:
Other questions of socket programming incSimple socket programming echo server and client
Calculating Server using TCP Sockets in c
Friday, 8 February 2019
Simple socket programming echo server and client
rlmdtechnical February 08, 2019 echo server and client in c, socket programming in c 2 comments
Hello friends ,this post contain a simple socket programming in c which echo the client message to the client(i.e. server will receive client message and send same message to the client i.e. echo server and client)
note : if you are beginner in computer network socket programming so i recommend to you please download and read first following pdf and then go through c code .
The Echo Server:After connecting to the basic Echo client, the basic Echo server (which is started first) simply echoes the string it receives back to the client, disconnects and terminates. The strings sent and received must be displayed on both client and server consoles.
The Echo Client:The basic Echo client connects to the Echo server and sends its data to the server. The data that the client sends is a string provided as the second client command-line argument.
server.c
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<unistd.h>
#include<sys/types.h>
#include<sys/socket.h>
#include<netinet/in.h>
#include<netdb.h>
#include<arpa/inet.h>
#define MAX_SIZE 1024
int main()
{
int sockfd,newsockfd;
socklen_t len;
char buffer[1024];
struct sockaddr_in serveraddr,clientaddr;
sockfd=socket(PF_INET,SOCK_STREAM,0);
serveraddr.sin_family=PF_INET;
serveraddr.sin_port=htons(12345);
serveraddr.sin_addr.s_addr=inet_addr("127.0.0.1");
bind(sockfd,(struct sockaddr*)&serveraddr,sizeof(serveraddr));
listen(sockfd,1024);
printf("\n\n Bind Done");
printf("\n\n Waiting for Client's Message.............");
printf("\n ");
len = sizeof(clientaddr);
newsockfd = accept(sockfd,(struct sockaddr*)&clientaddr,&len);
recv(newsockfd,buffer,MAX_SIZE,0);
printf("\n Client's Message : %s\n",buffer);
send(newsockfd,buffer,MAX_SIZE,0);
memset(buffer,'\0', MAX_SIZE);
return 0;
}
client.c
#include<stdio.h>
#include<stdlib.h>
#include<unistd.h>
#include<string.h>
#include<netinet/in.h>
#include<sys/socket.h>
#include<stdio_ext.h>
#include<arpa/inet.h>
#include<ctype.h>
#define MAX_SIZE 2048
#define QUEUE_LIMIT 12
int main()
{
int clientsocket,count=0;
char buffer[MAX_SIZE];
struct sockaddr_in serverAddress;
clientsocket=socket(PF_INET,SOCK_STREAM,IPPROTO_TCP);
serverAddress.sin_family=AF_INET;
serverAddress.sin_port=htons(12345);
serverAddress.sin_addr.s_addr=inet_addr("127.0.0.1");
memset(buffer,'\0', MAX_SIZE);
memset(buffer,'\0', MAX_SIZE);
connect(clientsocket,(struct sockaddr *) &serverAddress,sizeof(serverAddress));
printf("\nEnter string:");
scanf("%s",buffer);
char *sms=buffer;
send(clientsocket,sms,MAX_SIZE,0);
memset(buffer,'\0', MAX_SIZE);
recv(clientsocket,buffer,MAX_SIZE,0);
printf("\n Message from server: %s\n",buffer);
memset(buffer,'\0', MAX_SIZE);
return 0;
}
note :- first run server program on terminal and then client on ano