Skip to main content

Posts

Showing posts with the label Networking

Addition of two numbers on Server sent from Client [TCP] using C

/* tcpClient.c */ #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> #include <netdb.h> #include <stdio.h> #include <unistd.h> #include <string.h> #include <strings.h> #define MAX_MSG 100 #define SERVER_ADDR "127.0.0.1" #define CLIENT_ADDR "127.0.0.1" #define SERVER_PORT 3786 #define CLIENT_PORT 8229  main () {   int sd, rc, i,n;   struct sockaddr_in clientAddr, servAddr;   char line[MAX_MSG];   /**********************************/   /* build server address structure */   /**********************************/   bzero((char *)&servAddr, sizeof(servAddr));   servAddr.sin_family = AF_INET;   servAddr.sin_addr.s_addr = inet_addr(SERVER_ADDR);   servAddr.sin_port = htons(SERVER_PORT); /*   bzero((char *)&servAddr, sizeof(servAddr));   servAddr.sin_family = AF_INET;   inet_aton(SERVER_ADDR, &servAddr.sin_addr);   servAddr.sin_port = htons(SERVER_PORT); */   /*****

Concatenation of two strings sent from Client on the Server - [ TCP ] using C

/* tcpClient.c */ #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> #include <netdb.h> #include <stdio.h> #include <unistd.h> #include <string.h> #include <strings.h> #define MAX_MSG 100 #define SERVER_ADDR "127.0.0.1" #define CLIENT_ADDR "127.0.0.1" #define SERVER_PORT 3786 #define CLIENT_PORT 8229  main () {   int sd, rc, i,n;   struct sockaddr_in clientAddr, servAddr;   char line[MAX_MSG];   /**********************************/   /* build server address structure */   /**********************************/   bzero((char *)&servAddr, sizeof(servAddr));   servAddr.sin_family = AF_INET;   servAddr.sin_addr.s_addr = inet_addr(SERVER_ADDR);   servAddr.sin_port = htons(SERVER_PORT); /*   bzero((char *)&servAddr, sizeof(servAddr));   servAddr.sin_family = AF_INET;   inet_aton(SERVER_ADDR, &servAddr.sin_addr);   servAddr.sin_port = htons(SERVER_PORT); */   /*****

UDP Client-Server Program (Command Line) using C

/* udpClient.c */ #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> #include <netdb.h> #include <stdio.h> #include<stdlib.h> #include <unistd.h> #include <string.h> #include <strings.h> #include <sys/time.h> #define MAX_MSG 100  main(int argc,char *argv[] ) {   int i, sd, rc, tempLen, n, portno;   struct sockaddr_in remoteServAddr, tempAddr;   struct sockaddr_in cliAddr;   char server[20];   char msg[MAX_MSG];   if(argc<3)     {          fprintf(stderr,"Usage : %s hostname port\n Press Ctrl+C",argv[0]);           }   portno=atoi(argv[2]);   for(i=0;i<20;i++)      server[i]=argv[1][i];     if(server==NULL)     {           printf("Error, no such host");         }   /**********************************/   /* build server address structure */   /**********************************/   bzero((char *)&remoteServAddr, sizeof(remoteServAddr));   remoteServA

UDP Client-Server Program using C

/* udpClient.c */ #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> #include <netdb.h> #include <stdio.h> #include <unistd.h> #include <string.h> #include <sys/time.h> #define MAX_MSG 100 #define SERVER_ADDR "127.0.0.1" #define SERVER_PORT 9227  main( ) {   int sd, rc, tempLen, n;   struct sockaddr_in cliAddr, remoteServAddr, tempAddr;   char msg[MAX_MSG];   /**********************************/   /* build server address structure */   /**********************************/   bzero((char *)&remoteServAddr, sizeof(remoteServAddr));   remoteServAddr.sin_family = AF_INET;   remoteServAddr.sin_addr.s_addr = inet_addr(SERVER_ADDR);   remoteServAddr.sin_port = htons(SERVER_PORT);   /**************************/   /* create datagram socket */   /**************************/   sd = socket(AF_INET,SOCK_DGRAM,0);   printf("successfully created datagram socket\n");   do {     /

TCP Echo Server - Echo Client Program using C

/* tcpechoServer.c */ #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> #include <netdb.h> #include <stdio.h> #include <unistd.h> #include <strings.h> #include <string.h> #define MAX_MSG 100 #define SERVER_ADDR "127.0.0.1" #define SERVER_PORT 3786  main ( ) {   int sd, newSd, cliLen, n;   struct sockaddr_in cliAddr, servAddr;   char line[MAX_MSG], line_r[MAX_MSG];   /**********************************/   /* build server address structure */   /**********************************/   bzero((char *)&servAddr, sizeof(servAddr));   servAddr.sin_family = AF_INET;   servAddr.sin_addr.s_addr = inet_addr(SERVER_ADDR);   servAddr.sin_port = htons(SERVER_PORT); /*   bzero((char *)&servAddr, sizeof(servAddr));   servAddr.sin_family = AF_INET;   inet_aton(SERVER_ADDR, &servAddr.sin_addr);   servAddr.sin_port = htons(SERVER_PORT); */   /************************/   /* create strea

Net Neutrality

What is net neutrality? If net neutrality was to be defined in a single line it would go like this: “The premise of net neutrality is that all data on the Internet should be treated equally.” Expanding on the above, a more comprehensive definition would be: “Net neutrality means that Internet service providers (like Airtel, Reliance etc. who are responsible for our broadband and mobile Internet connections) shouldn’t be allowed to give preferential treatment to select websites, online services or apps. These ISPs should also not be allowed to discriminate against any websites, online services or apps.” Net neutrality means Internet that allows everyone to communicate freely. It means a service provider should allow access to all content and applications regardless of the source and no websites or pages should be blocked, as long as they aren’t illegal. All websites can co-exist without hampering others. All websites are accessible at the same speed and no particular website of applicat

Network Topologies

What is a Topology? The physical topology of a network refers to the configuration of cables, computers, and other peripherals. Types: Linear Bus Ring Star Mesh Tree Intersecting Ring Hybrid Irregular Point to Point The simplest topology is a permanent link between two end points is point to point.. In this technology a separate connection is made between two communication channels. Bus Topology  Bus Topology is the simplest of network topologies. In this type of topology, all the nodes (computers as well as servers) are connected to the single cable (called bus), by the help of interface connectors. This central cable is the backbone of the network and is known as Bus (thus the name). Every workstation communicates with the other device through this Bus.  A signal from the source is broadcasted and it travels to all workstations connected to bus cable. Although the message is broadcasted but only the intended recipient, whose MAC address or IP address matches, accepts it. If the MAC /

What is a Protocol?

A protocol is a set of rules that governs the data communications between computers on a network. In order for two computers to talk to each other, they must be speaking the same language. It is an agreement that governs the procedure used to exchange information between two co-operating entities. The agreement usually includes how much information is to be sent, how often it is sent, how to recover transmission errors, who to receive the information etc.. In general, a protocol will include definition of message format, sequencing rules, concerning messages and interpretation rules concerning messages transferred in proper sequence. Many different types of network protocols and standards are required to ensure that your computer (no matter which operating system, network card, or application you are using) can communicate with another computer located on the next desk or half-way around the world. The OSI (Open Systems Interconnection) Reference Model defines seven layers of networkin

What is a Network?

A computer network or data network is a telecommunications network which allows computers to exchange data. A network consists of two or more computers that are linked in order to share resources (such as printers and CDs), exchange files, or allow electronic communications. The computers on a network may be linked through cables, telephone lines, radio waves, satellites, or infrared light beams. Data is transferred in the form of packets. The connections between nodes are established using either cable media or wireless media. The best-known computer network is the Internet.  Two very common types of networks include: • Local Area Network (LAN) • Wide Area Network (WAN) There are also Metropolitan Area Networks (MAN) Wireless LAN (WLAN) Wireless WAN (WWAN) Campus Area Network, Controller Area Network, or sometimes Cluster Area Network (CAN) Storage Area Network, System Area Network, Server Area Network or sometimes Small Area Network  (SAN) Personal Area Network (PAN) Desk Area Networ