Interview Questions Answers.ORG
Interviewer And Interviewee Guide
Interviews
Quizzes
Home
Quizzes
Interviews Coding/Programming Interviews:Active Template Library (ATL)ActiveXApplication DeveloperArtificial intelligenceAssemblyAssociate Software EngineerAWKAWTC ProgrammingC++ ProgrammingCGI PerlCGI ProgrammingCMMICobolCritical ReasoningData Structures TreesDCOM COMDelphiDTDE4XExtensible Stylesheet Language (XSL)FortranFull-Stack DeveloperHaskellHTML DOMILUIPhone DeveloperJasper Reports DeveloperJava DeveloperLisp ProgrammingLotus NotesMicrosoft Foundation Class (MFC)Mobile DeveloperMVC DeveloperNode.jsOOPPascalPerl ProgrammingPHPPHP DeveloperProgrammingProgramming AlgorithmsProgramming ConceptsPythonRubyRuby on RailsRuby on Rails DeveloperSenior Front End DeveloperSenior Software DeveloperSignature ProgramSOASocket ProgrammingSoftware Development EngineerSoftware engineeringSr. PHP ProgrammerStack And QueueSTLSwift DeveloperTCL (Tool Command Language)Team Leader Android DeveloperUMLUnity 2D Games DeveloperUnity 3D DeveloperUnity DeveloperVBA (Visual Basic for Applications)Visual Basic (VB)Visual C++Web DevelopmentWin32APIWindows ProgramingWordPress DevelopmentWSDLXFormsXHTMLXLinkXMLXPathXQueryXSL-FOXSLT
Copyright © 2018. All Rights Reserved
Socket Programming Interview Question:
What is Whois Client?
Submitted by: AdministratorWhois Client: This is whois, a very simple and generic whois client. This client, unlike the classic whois client, does not check for supported flags at the client side, except for -h (whois host) and -p (whois port).
The whois(1) client makes a TCP/IP connection
to the server and conducts the kind of protocol
that you would type if you where to make
a connection by hand:
[7:30am julian] whois reggers
There were 1 matches on your request.
Full Name: Quinton, Reg
Department: Info Tech Svcs
Room: NSC 214
Phone: 679-2111x(6026)
Index Key: 481800
Machine Address: reggers@julian.uuu.com
Directory Addresses: reg.quinton@uuu.com
: r.quinton@uuu.com
: reggers@uuu.com
: quinton@uuu.com
For more information try 'whois help'.
The client sends the command "reggers", the server sends back the answer and the client displays the answer received to the user. When the server is finished the connection is closed.
Sample code: whois(1) client
sub tcpopen {
use Socket; # need socket interface
my($server, $service) = @_;# args to this function
my($proto, $port, $iaddr); # local variables
my($handle)="$server::$service";
# localized obscure handle
die("550:Cannot getprotobyname('tcp')
")
unless ($proto = getprotobyname('tcp'));
die("550:Cannot getservbyname($service)
")
unless ($port = getservbyname($service, 'tcp'));
die("550:Cannot gethostbyname($server)
")
unless ($iaddr = gethostbyname($server));
die("550:Cannot create socket
")
unless socket($handle, PF_INET, SOCK_STREAM, $proto);
die("550:Cannot connect($service://$server)
")
unless connect($handle, sockaddr_in($port, $iaddr));
# unbuffered I/O to that service
select($handle); $| = 1; select(STDOUT); $| = 1;
return($handle);
}
Submitted by: Administrator
The whois(1) client makes a TCP/IP connection
to the server and conducts the kind of protocol
that you would type if you where to make
a connection by hand:
[7:30am julian] whois reggers
There were 1 matches on your request.
Full Name: Quinton, Reg
Department: Info Tech Svcs
Room: NSC 214
Phone: 679-2111x(6026)
Index Key: 481800
Machine Address: reggers@julian.uuu.com
Directory Addresses: reg.quinton@uuu.com
: r.quinton@uuu.com
: reggers@uuu.com
: quinton@uuu.com
For more information try 'whois help'.
The client sends the command "reggers", the server sends back the answer and the client displays the answer received to the user. When the server is finished the connection is closed.
Sample code: whois(1) client
sub tcpopen {
use Socket; # need socket interface
my($server, $service) = @_;# args to this function
my($proto, $port, $iaddr); # local variables
my($handle)="$server::$service";
# localized obscure handle
die("550:Cannot getprotobyname('tcp')
")
unless ($proto = getprotobyname('tcp'));
die("550:Cannot getservbyname($service)
")
unless ($port = getservbyname($service, 'tcp'));
die("550:Cannot gethostbyname($server)
")
unless ($iaddr = gethostbyname($server));
die("550:Cannot create socket
")
unless socket($handle, PF_INET, SOCK_STREAM, $proto);
die("550:Cannot connect($service://$server)
")
unless connect($handle, sockaddr_in($port, $iaddr));
# unbuffered I/O to that service
select($handle); $| = 1; select(STDOUT); $| = 1;
return($handle);
}
Submitted by: Administrator
Copyright 2007-2024 by Interview Questions Answers .ORG All Rights Reserved.
https://InterviewQuestionsAnswers.ORG.
https://InterviewQuestionsAnswers.ORG.