JNTU

JNTU B.Tech III NETWORK PROGRAMMING Previous Question Paper (August - 2022 - R18)

B.Tech | III | III-II | R18 | August - 2022

Answer PaperPaper Code: 156CAMaximum Marks: 75Time: 3 Hours

Answer any five questions. All questions carry equal marks.

Main

115 marks
a

Write the syntax for readn() and writen() functions and explain its usage.

6 marks

Answer

The readn() and writen() functions are wrapper functions used to handle partial reads and writes in network programming, ensuring that the requested number of bytes is fully processed even if interrupted by signals or partial data availability.

ssize_t readn(int fd, void *ptr, size_t n);
ssize_t writen(int fd, const void *ptr, size_t n);

These functions are necessary because the standard read() and write() system calls may return fewer bytes than requested if a signal interrupts the call or if the socket buffer is full/empty. readn() continues reading in a loop until exactly n bytes are read or an error/EOF occurs. Similarly, writen() ensures that all n bytes are written to the descriptor by repeatedly calling write() and updating the pointer and remaining count until the entire buffer is sent.

b

List and explain various byte manipulation functions with clear syntax.

9 marks

Answer

Byte manipulation functions are used to initialize, copy, or compare blocks of memory, which is essential when working with socket address structures like sockaddr_in.

  • bzero(): Sets all bytes in a memory area to zero.
    void bzero(void *dest, size_t nbytes);
  • bcopy(): Copies nbytes from source to destination. Note that the arguments are in the order (src, dest).
    void bcopy(const void *src, void *dest, size_t nbytes);
  • bcmp(): Compares two memory areas for equality, returning 0 if identical.
    int bcmp(const void *ptr1, const void *ptr2, size_t nbytes);
  • memset(): A more portable alternative to bzero(), setting n bytes of memory to a specific value c.
    void *memset(void *s, int c, size_t n);
  • memcpy(): Similar to bcopy() but with standard C syntax (dest, src, n).
    void *memcpy(void *dest, const void *src, size_t n);
  • memcmp(): Compares n bytes of two memory areas.
    int memcmp(const void *ptr1, const void *ptr2, size_t n);
2

Explain the following elementary socket functions with neat syntax and example: a) socket() b) bind() c) connect() d) listen() e) accept()

15 marks

Answer

Sign in to view the complete answer paper.

3

Write down the programs for TCP echo server and TCP echo client. Explain the function that echos data on a socket and the function for client processing loop.

15 marks

Answer

Sign in to view the complete answer paper.

415 marks
a

Describe signal-driven I/O model and Asynchronous I/O model with neat diagrams.

9 marks

Answer

Sign in to view the complete answer paper.

b

Give the syntax of select() function and describe its basic functionality.

6 marks

Answer

Sign in to view the complete answer paper.

5

List and explain various IPv4 and IPv6 socket options.

15 marks

Answer

Sign in to view the complete answer paper.

615 marks
a

Give a detailed syntax and explanation of recvmsg() and sendmsg() functions and summarize various I/O flags of it.

9 marks

Answer

Sign in to view the complete answer paper.

b

Give the basic functionality of fcntl() function.

6 marks

Answer

Sign in to view the complete answer paper.

7

Explain the following functions with an illustrative example code:

15 marks
a

gethostbyname()

8 marks

Answer

Sign in to view the complete answer paper.

b

gethostbyaddr()

7 marks

Answer

Sign in to view the complete answer paper.

8

Give an overview of the traceroute program to determine IP datagrams path from our host to other destination with an illustrative program and flowchart.

15 marks

Answer

Sign in to view the complete answer paper.

About this paper

This page contains the solved question paper with answers of NETWORK PROGRAMMING from JNTU for B.Tech CSE III III-II, August - 2022, R18.

For the question paper without answers, switch to the Question Paper tab.

Other papers in NETWORK PROGRAMMING

Loading Question Papers

Fetching data from database...