#include <stdio.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <string.h>
#include <stdlib.h>
int main()
{
int sd, sd2, clilen, sport, i, client_socket, count = 0, val;
int port;
char data[50], senderdata[50];
int window_size;
int frame = 0;
int ACK;
struct sockaddr_in servaddr, cliaddr;
printf("Enter Server Port : ");
scanf("%d", &sport;);
printf("Server Port : %dn", sport);
sd = socket(AF_INET, SOCK_STREAM, 0);
if (sd < 0)
{
printf("Can't create Socketn");
}
else
{
printf("Socket Createdn");
}
servaddr.sin_family = AF_INET;
servaddr.sin_addr.s_addr = htonl(INADDR_ANY);
servaddr.sin_port = htons(sport);
sd2 = bind(sd, (struct sockaddr *)&servaddr;, sizeof(servaddr));
if (sd2 < 0)
{
printf("Can't Bindn");
}
else
{
printf("Bindedn");
}
listen(sd, 5);
clilen = sizeof(cliaddr);
client_socket = accept(sd, (struct sockaddr *)&cliaddr;, &clilen;);
if (client_socket < 0)
{
printf("Can't Acceptn");
}
else
{
printf("Acceptedn");
}
recv(client_socket, &window;_size, sizeof(window_size), 0);
while (frame < window_size)
{
for (i = 0; i < window_size; i++)
{
recv(client_socket, &frame;, sizeof(frame), 0);
printf("Transmitted frames received from the Clientn");
frame++;
if (frame == window_size)
{
break;
}
}
printf("nEnter the negative acknowledgment to be sent to the Client : ");
scanf("%d", &ACK;);
send(client_socket, &ACK;, sizeof(ACK), 0);
if (ACK == window_size)
{
break;
}
else
{
frame = ACK;
}
}
return 0;
}
{"html5":"htmlmixed","css":"css","javascript":"javascript","php":"php","python":"python","ruby":"ruby","lua":"text\/x-lua","bash":"text\/x-sh","go":"go","c":"text\/x-csrc","cpp":"text\/x-c++src","diff":"diff","latex":"stex","sql":"sql","xml":"xml","apl":"apl","asterisk":"asterisk","c_loadrunner":"text\/x-csrc","c_mac":"text\/x-csrc","coffeescript":"text\/x-coffeescript","csharp":"text\/x-csharp","d":"d","ecmascript":"javascript","erlang":"erlang","groovy":"text\/x-groovy","haskell":"text\/x-haskell","haxe":"text\/x-haxe","html4strict":"htmlmixed","java":"text\/x-java","java5":"text\/x-java","jquery":"javascript","mirc":"mirc","mysql":"sql","ocaml":"text\/x-ocaml","pascal":"text\/x-pascal","perl":"perl","perl6":"perl","plsql":"sql","properties":"text\/x-properties","q":"text\/x-q","scala":"scala","scheme":"text\/x-scheme","tcl":"text\/x-tcl","vb":"text\/x-vb","verilog":"text\/x-verilog","yaml":"text\/x-yaml","z80":"text\/x-z80"}