Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Running a program in Java about slidsender and slidreceiver with a brief explanation what each one is doing. slidreceiver import java.net.*; import java.io.*; class slidreceiver

Running a program in Java about slidsender and slidreceiver with a brief explanation what each one is doing.

slidreceiver

import java.net.*; import java.io.*; class slidreceiver

{

public static void main(String a[])throws Exception

{

Socket s=new Socket(InetAddress.getLocalHost(),10); DataInputStream in=new

DataInputStream(s.getInputStream()); PrintStream p=new

PrintStream(s.getOutputStream());

int i=0,rptr=-1,nf,rws=8; String rbuf[]=new String[8]; String ch;

System.out.println(); do

{

nf=Integer.parseInt(in.readLine()); if(nf<=rws-1)

{

for(i=1;i<=nf;i++)

{

rptr=++rptr%8; rbuf[rptr]=in.readLine();

System.out.println("The received Frame " +rptr+" is : "+rbuf[rptr]);

}

rws-=nf; System.out.println(" Acknowledgment sent "); p.println(rptr+1);

rws+=nf; }

else break;

ch=in.readLine();

}

while(ch.equals("yes"));

}

}

slidsender

import java.net.*;
import java.io.*;
import java.rmi.*;
public class slidsender
{
public static void main(String a[]) throws Exception
{
ServerSocket ser=new ServerSocket(1024);
Socket s=ser.accept();
DataInputStream in=new DataInputStream(System.in);
DataInputStream in1=new DataInputStream(s.getInputStream());
String sbuff[]=new String[8];
PrintStream p;
int sptr=0,sws=8,nf,ano,i;
String ch;
do
{
p=new PrintStream(s.getOutputStream());
System.out.print("Enter the no. of frames : ");
nf=Integer.parseInt(in.readLine());
p.println(nf);
if(nf<=sws-1) {
System.out.println("Enter "+nf+" Messages to be send ");
for(i=1;i<=nf;i++) {
sbuff[sptr]=in.readLine();
p.println(sbuff[sptr]);
sptr=++sptr%8;} sws-=nf;
System.out.print("Acknowledgment received");
ano=Integer.parseInt(in1.readLine());
System.out.println(" for "+ano+" frames"); sws+=nf;
} else
{
System.out.println("The no. of frames exceeds window size");
break;
}
System.out.print(" Do you wants to send some more frames : ");
ch=in.readLine();
p.println(ch);
}
while(ch.equals("yes"));
s.close();
}

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Concepts Of Database Management

Authors: Joy L. Starks, Philip J. Pratt, Mary Z. Last

9th Edition

1337093424, 978-1337093422

More Books

Students also viewed these Databases questions

Question

4. Explain how to use fair disciplinary practices.

Answered: 1 week ago

Question

3. Give examples of four fair disciplinary practices.

Answered: 1 week ago