c) set history save on
a) displays the last 10 commands in the command history
b) displays the current default base for numeric display
b) set
a) convenience variables
d) all of the mentioned
a) error
Explanation:
The structure used for AF_UNIX if sockaddr_un.
Output:
[root@localhost google]# gcc -o san san.c
san.c: In function 'main':
san.c:14:6: error: 'struct sockaddr_in' has no member named 'sun_family'
san.c:15:2: warning: incompatible implicit declaration of built-in function 'strcpy' [enabled by default]
san.c:15:13: error: 'struct sockaddr_in' has no member named 'sun_path'
[root@localhost google]#
c) error
Explanation:
The syntax of the connect() is wrong. connect() should be used in client program only.
Ouptut:
[root@localhost google]# gcc -o san san.c
san.c: In function 'main':
san.c:20:46: warning: passing argument 3 of 'connect' makes integer from pointer without a cast [enabled by default]
/usr/include/sys/socket.h:129:12: note: expected 'socklen_t' but argument is of type 'int *'
[root@localhost google]#
a) this program will print the string "google"
Explanation:
The first argument of the bind() is not a valid file descriptor in this program.
Output:
[root@localhost google]# gcc -o san san.c
[root@localhost google]# ./san
Sanfoudnry
[root@localhost google]#
d) 3
Explanation:
The socket() returns the lowest available file descriptor and in this program i.e. 3.
Output:
[root@localhost google]# gcc -o san san.c
[root@localhost google]# ./san
3
[root@localhost google]#
b) the process will remain block
Explanation:
There is no peding request in the queue for listening socket "san_sock".
Output:
[root@localhost google]# gcc -o san san.c
[root@localhost google]# ./san
^Z
[4]+ Stopped ./san
[root@localhost google]#
d) 3
Explanation:
The second argument of listen() specifies the length for the queue for pending connections.
c) in the present working directory
Output:
[root@localhost google]# ls
san.c
[root@localhost google]# gcc -o san san.c
[root@localhost google]# ./san
[root@localhost google]# ls
san san.c san_sock
[root@localhost google]#
d) none of the mentioned
Explanation:
To use socket(), the header files sys/types.h and sys/socket.h are required.
Output:
[root@localhost google]# gcc -o san san.c
san.c: In function 'main':
san.c:6:21: error: 'AF_UNIX' undeclared (first use in this function)
san.c:6:21: note: each undeclared identifier is reported only once for each function it appears in
san.c:6:29: error: 'SOCK_STREAM' undeclared (first use in this function)
[root@localhost google]#
d) none of the mentioned
Explanation:
The program will not work properly because the file descriptor is not available in the for listen() and accept().
Output:
[root@localhost google]# gcc -o san san.c
[root@localhost google]# ./san
accept: Success
listen: Bad file descriptor
[root@localhost google]#
d) none of the mentioned
Explanation:
The listen() must always be used before accept().
Output:
[root@localhost google]# gcc -o san san.c
[root@localhost google]# ./san
accept: Invalid argument
[root@localhost google]#
b) -1
Explanation:
The shutdown() is used to close a socket and the first argument in shutdown() is socket.
Output:
[root@localhost google]# gcc -o san san.c
[root@localhost google]# ./san
-1
[root@localhost google]#