Linux Socket Programming Interview Questions And Answers

Download Linux Socket Programming Interview Questions and Answers PDF

Elevate your Linux Socket Programming interview readiness with our detailed compilation of 6 questions. These questions are specifically selected to challenge and enhance your knowledge in Linux Socket Programming. Perfect for all proficiency levels, they are key to your interview success. Get the free PDF download to access all 6 questions and excel in your Linux Socket Programming interview. This comprehensive guide is essential for effective study and confidence building.

6 Linux Socket Programming Questions and Answers:

Linux Socket Programming Job Interview Questions Table of Contents:

Linux Socket Programming Job Interview Questions and Answers
Linux Socket Programming Job Interview Questions and Answers

1 :: How to get client port number in server socket programming?

After accepting connection on socket of server side. we can
get the client ip address and port by to functions. These
functions are belonging in "/usr/include/arpa/inet.h" header
file.

Here is some scratch from the code.
socket2 = accept(socket1, (struct sockaddr *)&client, &addrlen);
printf("%s\n",inet_ntoa(client.sin_addr));
printf("%d\n",(int) ntohs(client.sin_port));
Read More

2 :: What is the difference between socket & port?

port : a particular port number on a host
socket: a host and a port

like
-> http port = 80
-> when you fire up google.com
the socket on the server side is google.com:80 this is the server side socket

on your local system where you are browsing the socket is
yourip:port above 1024
Read More

3 :: Why bind system call is required in socket programming?

bind system call assigns a name to the unnamed socket.
Binding an address allows a process to register its address
with the system. This makes it possible for other process to
find it.
Read More

4 :: What is the difference between a process task and threads and what are the things that are acquired by the child process from the parent process?

Process is an executing program with several components and
proprieties.
1.exec thread
2. PID
3. priority
4. memory context
5. enviornment
6. file descriptors
7. security credentials.
processes began through a process called "fork and exec".
that is when one command starts another, the child process
first forks , the kernel copying over pages of memory from
the present process to a new location for the child process.
The child then execs, executing the new command and
overwriting the data.the thread is , which controls the flow
of the process. A process needs at least one thread.
Read More

5 :: What is the difference between a process task and threads?

process and task as synonymous. One or more threads
together form a process. The threads, two or more belong to
same process, share same address space of the process and
can access all the global variable of the process.
Where as two processes can't access each other's address
space and hence cant access their global variable. Two
processes can talk with each other using IPC.

what are the things that are acquired by the child
process from the parent process?

File descriptors [including socket descriptor].
The whole text segment.
Environment variables.
PPID is PID of parent process.
Read More

6 :: What is the difference between fork() & exec()?

fork() created a newly independent process that has it's own
space in memory and also has own permission depends upon
what you assign

Using exec() the created process is a sub thread of calling
process. They also share area in memory and so that also
share all permission and resources.
Read More