SlideShare uma empresa Scribd logo
1 de 21
Networking
In the world of computers, networking is
the practice of linking two or more
computing devices together for the purpose
of sharing data. Networks are built with a
mix of computer hardware and computer
software.
• A network consists of two or more computers
that are linked in order to share resources
(such as printers and CDs), exchange files, or
allow electronic communications.
• The computers on a network may be linked
through cables, telephone lines, radio waves,
satellites, or infrared light beams.
• common types of networks :
– Local Area Network(LAN)
– Wide Area Network(WAN)
– Metropolitan area Network(MAN)
Advantages
• User access control , Information storing and
sharing, Connections ,Services, Internet,
sharing resources, Flexible Access.
Disadvantages
• Expensive to Install, Requires Administrative
Time, Servers Fail, Cables May Break, Security
• A computer network consists of machines
interconnected by communication channels.
• We call these machines hosts or routers .
• Hosts are computers that run applications
such as your Web browser, the application
programs running on hosts are really the users
of the network.
• Routers are machines whose job is to relay or
forward information from one communication
channel to another.
• By information we here mean a sequences of
bytes that are constructed and interpreted by
programs.
• In the context of computer networks these
byte sequences are generally called packets .
• A protocol is an agreement about the packets
exchanged .
• TCP is designed to detect and recover from
the losses, duplications, and other errors that
may occur in the host-to-host channel
provided by IP.
• TCP provides a reliable byte-stream channel.
TCP/IP network
Socket
• A socket is one end-point of a two-way
communication link between two programs
running on the network.
• A server application normally listens to a specific
port waiting for connection requests from a client.
• When a connection request arrives, the client and
the server establish a dedicated connection over
which they can communicate.
• During the connection process, the client is
assigned a local port number, and binds a socket to
it. The client talks to the server by writing to the
socket and gets information from the server by
reading from it.
• In computer networking, a port number is
part of the addressing information used to
identify the senders and receivers of
messages.
• Port numbers are most commonly used
withTCP/IP connections. Home network
routers and computer software work with
ports and sometimes allow you to
configure port number settings. These port
numbers allow different applications on the
same computer to share network resources
simultaneously.
logical relationships among applications
Socket Addresses
• IPv4 uses 32-bit binary addresses to identify
communicating hosts.
• .NET encapsulates the IP addresses
abstraction in the IPAddress class which can
take a long integer IP argument in its
constructor, or process a string with the
dotted-quad representation of an IP address
using its Parse()method.
• The Dns class also provides a mechanism to
look up, or resolve names to IP addresses
(e.g., server.example.com ).
• a single server to resolve to multiple IP
addresses or name aliases, the results are
returned in a container class IPHostEntry,
which contains an array of one or more string.
• The Dns class has several methods for
resolving IP addresses. The GetHostName()
method takes no arguments and returns a
string containing the local host name.
• The GetHostByName() and Resolve()methods
are basically identical, they take a string
argument containing the host name to be
looked up and returns the IP address and
host name.
• Information for the supplied input in the form
of an IPHostEntry class instance. The Get-
HostByAddress() method takes a string
argument containing the dotted-quad string
representation of an IP address and also
returns host information in an IPHostEntry
instance.
using System.Net;
using System.Net.Sockets;
namespace socket1
{
class IPAddressExample
{
static void PrintHostInfo(String host)
{
try {
IPHostEntry hostInfo;
// Attempt to resolve DNS for given host or address
hostInfo = Dns.Resolve(host);
//Resolve:-looked up and returns the IP address and host name
// Display the primary host name
Console.WriteLine(" tCanonical Name : " + hostInfo.HostName);
// Display list of IP addresses for this host
Console.Write(" tIP Addresses: ");
foreach (IPAddress ipaddr in hostInfo.AddressList)
{
Console.Write(ipaddr.ToString()+"");
}
Console.WriteLine(" n");
}
catch (Exception)
{
Console.WriteLine(" tUnable to resolve host:"+ host+ "n");
}
}
static void Main(string[] args) {
// Get and print local host info
try {
Console.WriteLine("Local Host:");
String localHostName = Dns.GetHostName();
Console.WriteLine(" tHost Name: " + localHostName);
PrintHostInfo(localHostName);
}
catch (Exception)
{
Console.WriteLine("Unable to resolve local hostn");
} }
}
TCP classes
• The transmission control protocol (TCP) classes
offer simple methods for connecting and
sending data between two endpoints. An
endpoint is the combination of an IP address
and a port number.
• Existing protocols have well defined port
numbers, for example, HTTP uses port 80, while
SMTP uses port 25.
• The Internet Assigned Number Authority (IANA),
(http://www.iana.org/) assigns port numbers to
these well-known services.
• Socket: Low-level class that deals with
managing connections. Classes such as
WebRequest, TcpClient, and UdpClient use
this class internally.
• NetworkStream: Derived from Stream.
Represents a stream of data from/to the
network.
• TcpClient: Enables you to create and use TCP
connections.
• TcpListener: Enables you to listen for incoming
TCP connection requests.
• The TcpListener class listens for incoming TCP
connections with the Start()method.
• When a connection request arrives you can
use the AcceptSocket() method to return a
socket for communication with the remote
machine, or use the AcceptTcpClient()method
to use a higher-level TcpClient object for
communication.
• UdpClient: Enables you to create connections
for UDP clients. (UDP is an alternative protocol
to TCP, but is much less widely used, mostly
on local networks.)

Mais conteúdo relacionado

Mais procurados

Internet protocols Report Slides
Internet protocols Report SlidesInternet protocols Report Slides
Internet protocols Report SlidesBassam Kanber
 
Basic Networking
Basic NetworkingBasic Networking
Basic NetworkingCEC Landran
 
IP adress and routing(networking)
IP adress and routing(networking)IP adress and routing(networking)
IP adress and routing(networking)welcometofacebook
 
Networks A2
Networks  A2Networks  A2
Networks A2aeneas
 
Et3003 sem2-1314-4 network layers i (ipv4 addressing)
Et3003 sem2-1314-4 network layers i (ipv4 addressing)Et3003 sem2-1314-4 network layers i (ipv4 addressing)
Et3003 sem2-1314-4 network layers i (ipv4 addressing)Tutun Juhana
 
Socket programming or network programming
Socket programming or network programmingSocket programming or network programming
Socket programming or network programmingMmanan91
 
Internet protocol (ip)
Internet protocol (ip)Internet protocol (ip)
Internet protocol (ip)junnubabu
 
Tcpip services and applications
Tcpip services and applicationsTcpip services and applications
Tcpip services and applicationsOnline
 
TCP/IP Introduction
TCP/IP Introduction TCP/IP Introduction
TCP/IP Introduction LJ PROJECTS
 
Network layers forwarding.docx
Network layers forwarding.docxNetwork layers forwarding.docx
Network layers forwarding.docxAnusuaBasu
 
Networking
NetworkingNetworking
NetworkingTuan Ngo
 
Report on ip addresses
Report on ip addressesReport on ip addresses
Report on ip addressesAmandeep Kaur
 
Tcp and introduction to protocol
Tcp and introduction to protocolTcp and introduction to protocol
Tcp and introduction to protocolSripati Mahapatra
 

Mais procurados (20)

Internet protocols Report Slides
Internet protocols Report SlidesInternet protocols Report Slides
Internet protocols Report Slides
 
Basic Networking
Basic NetworkingBasic Networking
Basic Networking
 
IP adress and routing(networking)
IP adress and routing(networking)IP adress and routing(networking)
IP adress and routing(networking)
 
Networks A2
Networks  A2Networks  A2
Networks A2
 
Et3003 sem2-1314-4 network layers i (ipv4 addressing)
Et3003 sem2-1314-4 network layers i (ipv4 addressing)Et3003 sem2-1314-4 network layers i (ipv4 addressing)
Et3003 sem2-1314-4 network layers i (ipv4 addressing)
 
Socket programming or network programming
Socket programming or network programmingSocket programming or network programming
Socket programming or network programming
 
TCP/IP Presentation
TCP/IP PresentationTCP/IP Presentation
TCP/IP Presentation
 
Internet protocol (ip)
Internet protocol (ip)Internet protocol (ip)
Internet protocol (ip)
 
IPv4
IPv4IPv4
IPv4
 
Network layer logical addressing
Network layer logical addressingNetwork layer logical addressing
Network layer logical addressing
 
TCP/IP
TCP/IPTCP/IP
TCP/IP
 
Tcpip services and applications
Tcpip services and applicationsTcpip services and applications
Tcpip services and applications
 
TCP/IP Introduction
TCP/IP Introduction TCP/IP Introduction
TCP/IP Introduction
 
Network layers forwarding.docx
Network layers forwarding.docxNetwork layers forwarding.docx
Network layers forwarding.docx
 
IP classes
IP classesIP classes
IP classes
 
Networking
NetworkingNetworking
Networking
 
Report on ip addresses
Report on ip addressesReport on ip addresses
Report on ip addresses
 
IPv4 Addressing
 IPv4 Addressing   IPv4 Addressing
IPv4 Addressing
 
Tcp and introduction to protocol
Tcp and introduction to protocolTcp and introduction to protocol
Tcp and introduction to protocol
 
The Internet Protocol version 4 (IPv4)
The Internet Protocol version 4 (IPv4)The Internet Protocol version 4 (IPv4)
The Internet Protocol version 4 (IPv4)
 

Semelhante a Networking and socket

09 Systems Software Programming-Network Programming.pptx
09 Systems Software Programming-Network Programming.pptx09 Systems Software Programming-Network Programming.pptx
09 Systems Software Programming-Network Programming.pptxKushalSrivastava23
 
chapter-4-networking hjgjjgj did hfhhfhj
chapter-4-networking hjgjjgj did hfhhfhjchapter-4-networking hjgjjgj did hfhhfhj
chapter-4-networking hjgjjgj did hfhhfhjAmitDeshai
 
+ Network Programming.pdf
+ Network Programming.pdf+ Network Programming.pdf
+ Network Programming.pdfOluwafolakeOjo
 
Network Programming in Java
Network Programming in JavaNetwork Programming in Java
Network Programming in JavaTushar B Kute
 
Network programming in Java
Network programming in JavaNetwork programming in Java
Network programming in JavaTushar B Kute
 
Sept 2017 internetworking
Sept 2017   internetworkingSept 2017   internetworking
Sept 2017 internetworkingshahin raj
 
SOHO Network Setup Tutorial
SOHO Network Setup Tutorial SOHO Network Setup Tutorial
SOHO Network Setup Tutorial junaidahmedsaba
 
Computer network coe351- part3-final
Computer network coe351- part3-finalComputer network coe351- part3-final
Computer network coe351- part3-finalTaymoor Nazmy
 
M.Florence Dayana Computer Networks Introduction
M.Florence Dayana   Computer Networks IntroductionM.Florence Dayana   Computer Networks Introduction
M.Florence Dayana Computer Networks IntroductionDr.Florence Dayana
 
RHSA_1_Chapter(11)_Resume_chaptre_11.pptx
RHSA_1_Chapter(11)_Resume_chaptre_11.pptxRHSA_1_Chapter(11)_Resume_chaptre_11.pptx
RHSA_1_Chapter(11)_Resume_chaptre_11.pptxAbdellahELMAMOUN
 
Networking.pptx
Networking.pptxNetworking.pptx
Networking.pptxEsubesisay
 
Internet architecture protocol
Internet architecture protocolInternet architecture protocol
Internet architecture protocolGLIM Digital
 
Unit-4 networking basics in java
Unit-4 networking basics in javaUnit-4 networking basics in java
Unit-4 networking basics in javaAmol Gaikwad
 
network fundamentals
network fundamentalsnetwork fundamentals
network fundamentalsSithu PM
 

Semelhante a Networking and socket (20)

09 Systems Software Programming-Network Programming.pptx
09 Systems Software Programming-Network Programming.pptx09 Systems Software Programming-Network Programming.pptx
09 Systems Software Programming-Network Programming.pptx
 
chapter-4-networking hjgjjgj did hfhhfhj
chapter-4-networking hjgjjgj did hfhhfhjchapter-4-networking hjgjjgj did hfhhfhj
chapter-4-networking hjgjjgj did hfhhfhj
 
+ Network Programming.pdf
+ Network Programming.pdf+ Network Programming.pdf
+ Network Programming.pdf
 
Network Programming in Java
Network Programming in JavaNetwork Programming in Java
Network Programming in Java
 
Network programming in Java
Network programming in JavaNetwork programming in Java
Network programming in Java
 
Sept 2017 internetworking
Sept 2017   internetworkingSept 2017   internetworking
Sept 2017 internetworking
 
SOHO Network Setup Tutorial
SOHO Network Setup Tutorial SOHO Network Setup Tutorial
SOHO Network Setup Tutorial
 
Computer network coe351- part3-final
Computer network coe351- part3-finalComputer network coe351- part3-final
Computer network coe351- part3-final
 
Computing 9
Computing 9Computing 9
Computing 9
 
Computer Networks basics
Computer Networks basicsComputer Networks basics
Computer Networks basics
 
Md13 networking
Md13 networkingMd13 networking
Md13 networking
 
M.Florence Dayana Computer Networks Introduction
M.Florence Dayana   Computer Networks IntroductionM.Florence Dayana   Computer Networks Introduction
M.Florence Dayana Computer Networks Introduction
 
lecture-2-tcp-ip.ppt
lecture-2-tcp-ip.pptlecture-2-tcp-ip.ppt
lecture-2-tcp-ip.ppt
 
RHSA_1_Chapter(11)_Resume_chaptre_11.pptx
RHSA_1_Chapter(11)_Resume_chaptre_11.pptxRHSA_1_Chapter(11)_Resume_chaptre_11.pptx
RHSA_1_Chapter(11)_Resume_chaptre_11.pptx
 
Networking
Networking Networking
Networking
 
28 networking
28  networking28  networking
28 networking
 
Networking.pptx
Networking.pptxNetworking.pptx
Networking.pptx
 
Internet architecture protocol
Internet architecture protocolInternet architecture protocol
Internet architecture protocol
 
Unit-4 networking basics in java
Unit-4 networking basics in javaUnit-4 networking basics in java
Unit-4 networking basics in java
 
network fundamentals
network fundamentalsnetwork fundamentals
network fundamentals
 

Último

Design Guidelines for Passkeys 2024.pptx
Design Guidelines for Passkeys 2024.pptxDesign Guidelines for Passkeys 2024.pptx
Design Guidelines for Passkeys 2024.pptxFIDO Alliance
 
Quantum Leap in Next-Generation Computing
Quantum Leap in Next-Generation ComputingQuantum Leap in Next-Generation Computing
Quantum Leap in Next-Generation ComputingWSO2
 
TEST BANK For Principles of Anatomy and Physiology, 16th Edition by Gerard J....
TEST BANK For Principles of Anatomy and Physiology, 16th Edition by Gerard J....TEST BANK For Principles of Anatomy and Physiology, 16th Edition by Gerard J....
TEST BANK For Principles of Anatomy and Physiology, 16th Edition by Gerard J....rightmanforbloodline
 
WSO2 Micro Integrator for Enterprise Integration in a Decentralized, Microser...
WSO2 Micro Integrator for Enterprise Integration in a Decentralized, Microser...WSO2 Micro Integrator for Enterprise Integration in a Decentralized, Microser...
WSO2 Micro Integrator for Enterprise Integration in a Decentralized, Microser...WSO2
 
Stronger Together: Developing an Organizational Strategy for Accessible Desig...
Stronger Together: Developing an Organizational Strategy for Accessible Desig...Stronger Together: Developing an Organizational Strategy for Accessible Desig...
Stronger Together: Developing an Organizational Strategy for Accessible Desig...caitlingebhard1
 
Hyatt driving innovation and exceptional customer experiences with FIDO passw...
Hyatt driving innovation and exceptional customer experiences with FIDO passw...Hyatt driving innovation and exceptional customer experiences with FIDO passw...
Hyatt driving innovation and exceptional customer experiences with FIDO passw...FIDO Alliance
 
Navigating Identity and Access Management in the Modern Enterprise
Navigating Identity and Access Management in the Modern EnterpriseNavigating Identity and Access Management in the Modern Enterprise
Navigating Identity and Access Management in the Modern EnterpriseWSO2
 
ERP Contender Series: Acumatica vs. Sage Intacct
ERP Contender Series: Acumatica vs. Sage IntacctERP Contender Series: Acumatica vs. Sage Intacct
ERP Contender Series: Acumatica vs. Sage IntacctBrainSell Technologies
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontologyjohnbeverley2021
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Zilliz
 
Event-Driven Architecture Masterclass: Challenges in Stream Processing
Event-Driven Architecture Masterclass: Challenges in Stream ProcessingEvent-Driven Architecture Masterclass: Challenges in Stream Processing
Event-Driven Architecture Masterclass: Challenges in Stream ProcessingScyllaDB
 
JavaScript Usage Statistics 2024 - The Ultimate Guide
JavaScript Usage Statistics 2024 - The Ultimate GuideJavaScript Usage Statistics 2024 - The Ultimate Guide
JavaScript Usage Statistics 2024 - The Ultimate GuidePixlogix Infotech
 
Working together SRE & Platform Engineering
Working together SRE & Platform EngineeringWorking together SRE & Platform Engineering
Working together SRE & Platform EngineeringMarcus Vechiato
 
2024 May Patch Tuesday
2024 May Patch Tuesday2024 May Patch Tuesday
2024 May Patch TuesdayIvanti
 
Tales from a Passkey Provider Progress from Awareness to Implementation.pptx
Tales from a Passkey Provider  Progress from Awareness to Implementation.pptxTales from a Passkey Provider  Progress from Awareness to Implementation.pptx
Tales from a Passkey Provider Progress from Awareness to Implementation.pptxFIDO Alliance
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Victor Rentea
 
Design and Development of a Provenance Capture Platform for Data Science
Design and Development of a Provenance Capture Platform for Data ScienceDesign and Development of a Provenance Capture Platform for Data Science
Design and Development of a Provenance Capture Platform for Data SciencePaolo Missier
 
JohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptxJohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptxJohnPollard37
 
Modernizing Legacy Systems Using Ballerina
Modernizing Legacy Systems Using BallerinaModernizing Legacy Systems Using Ballerina
Modernizing Legacy Systems Using BallerinaWSO2
 
Portal Kombat : extension du réseau de propagande russe
Portal Kombat : extension du réseau de propagande russePortal Kombat : extension du réseau de propagande russe
Portal Kombat : extension du réseau de propagande russe中 央社
 

Último (20)

Design Guidelines for Passkeys 2024.pptx
Design Guidelines for Passkeys 2024.pptxDesign Guidelines for Passkeys 2024.pptx
Design Guidelines for Passkeys 2024.pptx
 
Quantum Leap in Next-Generation Computing
Quantum Leap in Next-Generation ComputingQuantum Leap in Next-Generation Computing
Quantum Leap in Next-Generation Computing
 
TEST BANK For Principles of Anatomy and Physiology, 16th Edition by Gerard J....
TEST BANK For Principles of Anatomy and Physiology, 16th Edition by Gerard J....TEST BANK For Principles of Anatomy and Physiology, 16th Edition by Gerard J....
TEST BANK For Principles of Anatomy and Physiology, 16th Edition by Gerard J....
 
WSO2 Micro Integrator for Enterprise Integration in a Decentralized, Microser...
WSO2 Micro Integrator for Enterprise Integration in a Decentralized, Microser...WSO2 Micro Integrator for Enterprise Integration in a Decentralized, Microser...
WSO2 Micro Integrator for Enterprise Integration in a Decentralized, Microser...
 
Stronger Together: Developing an Organizational Strategy for Accessible Desig...
Stronger Together: Developing an Organizational Strategy for Accessible Desig...Stronger Together: Developing an Organizational Strategy for Accessible Desig...
Stronger Together: Developing an Organizational Strategy for Accessible Desig...
 
Hyatt driving innovation and exceptional customer experiences with FIDO passw...
Hyatt driving innovation and exceptional customer experiences with FIDO passw...Hyatt driving innovation and exceptional customer experiences with FIDO passw...
Hyatt driving innovation and exceptional customer experiences with FIDO passw...
 
Navigating Identity and Access Management in the Modern Enterprise
Navigating Identity and Access Management in the Modern EnterpriseNavigating Identity and Access Management in the Modern Enterprise
Navigating Identity and Access Management in the Modern Enterprise
 
ERP Contender Series: Acumatica vs. Sage Intacct
ERP Contender Series: Acumatica vs. Sage IntacctERP Contender Series: Acumatica vs. Sage Intacct
ERP Contender Series: Acumatica vs. Sage Intacct
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
Event-Driven Architecture Masterclass: Challenges in Stream Processing
Event-Driven Architecture Masterclass: Challenges in Stream ProcessingEvent-Driven Architecture Masterclass: Challenges in Stream Processing
Event-Driven Architecture Masterclass: Challenges in Stream Processing
 
JavaScript Usage Statistics 2024 - The Ultimate Guide
JavaScript Usage Statistics 2024 - The Ultimate GuideJavaScript Usage Statistics 2024 - The Ultimate Guide
JavaScript Usage Statistics 2024 - The Ultimate Guide
 
Working together SRE & Platform Engineering
Working together SRE & Platform EngineeringWorking together SRE & Platform Engineering
Working together SRE & Platform Engineering
 
2024 May Patch Tuesday
2024 May Patch Tuesday2024 May Patch Tuesday
2024 May Patch Tuesday
 
Tales from a Passkey Provider Progress from Awareness to Implementation.pptx
Tales from a Passkey Provider  Progress from Awareness to Implementation.pptxTales from a Passkey Provider  Progress from Awareness to Implementation.pptx
Tales from a Passkey Provider Progress from Awareness to Implementation.pptx
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Design and Development of a Provenance Capture Platform for Data Science
Design and Development of a Provenance Capture Platform for Data ScienceDesign and Development of a Provenance Capture Platform for Data Science
Design and Development of a Provenance Capture Platform for Data Science
 
JohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptxJohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptx
 
Modernizing Legacy Systems Using Ballerina
Modernizing Legacy Systems Using BallerinaModernizing Legacy Systems Using Ballerina
Modernizing Legacy Systems Using Ballerina
 
Portal Kombat : extension du réseau de propagande russe
Portal Kombat : extension du réseau de propagande russePortal Kombat : extension du réseau de propagande russe
Portal Kombat : extension du réseau de propagande russe
 

Networking and socket

  • 1. Networking In the world of computers, networking is the practice of linking two or more computing devices together for the purpose of sharing data. Networks are built with a mix of computer hardware and computer software.
  • 2. • A network consists of two or more computers that are linked in order to share resources (such as printers and CDs), exchange files, or allow electronic communications. • The computers on a network may be linked through cables, telephone lines, radio waves, satellites, or infrared light beams. • common types of networks : – Local Area Network(LAN) – Wide Area Network(WAN) – Metropolitan area Network(MAN)
  • 3. Advantages • User access control , Information storing and sharing, Connections ,Services, Internet, sharing resources, Flexible Access. Disadvantages • Expensive to Install, Requires Administrative Time, Servers Fail, Cables May Break, Security
  • 4. • A computer network consists of machines interconnected by communication channels. • We call these machines hosts or routers . • Hosts are computers that run applications such as your Web browser, the application programs running on hosts are really the users of the network. • Routers are machines whose job is to relay or forward information from one communication channel to another.
  • 5. • By information we here mean a sequences of bytes that are constructed and interpreted by programs. • In the context of computer networks these byte sequences are generally called packets . • A protocol is an agreement about the packets exchanged . • TCP is designed to detect and recover from the losses, duplications, and other errors that may occur in the host-to-host channel provided by IP. • TCP provides a reliable byte-stream channel.
  • 7. Socket • A socket is one end-point of a two-way communication link between two programs running on the network. • A server application normally listens to a specific port waiting for connection requests from a client. • When a connection request arrives, the client and the server establish a dedicated connection over which they can communicate. • During the connection process, the client is assigned a local port number, and binds a socket to it. The client talks to the server by writing to the socket and gets information from the server by reading from it.
  • 8. • In computer networking, a port number is part of the addressing information used to identify the senders and receivers of messages. • Port numbers are most commonly used withTCP/IP connections. Home network routers and computer software work with ports and sometimes allow you to configure port number settings. These port numbers allow different applications on the same computer to share network resources simultaneously.
  • 10. Socket Addresses • IPv4 uses 32-bit binary addresses to identify communicating hosts. • .NET encapsulates the IP addresses abstraction in the IPAddress class which can take a long integer IP argument in its constructor, or process a string with the dotted-quad representation of an IP address using its Parse()method. • The Dns class also provides a mechanism to look up, or resolve names to IP addresses (e.g., server.example.com ).
  • 11. • a single server to resolve to multiple IP addresses or name aliases, the results are returned in a container class IPHostEntry, which contains an array of one or more string. • The Dns class has several methods for resolving IP addresses. The GetHostName() method takes no arguments and returns a string containing the local host name.
  • 12. • The GetHostByName() and Resolve()methods are basically identical, they take a string argument containing the host name to be looked up and returns the IP address and host name. • Information for the supplied input in the form of an IPHostEntry class instance. The Get- HostByAddress() method takes a string argument containing the dotted-quad string representation of an IP address and also returns host information in an IPHostEntry instance.
  • 13. using System.Net; using System.Net.Sockets; namespace socket1 { class IPAddressExample { static void PrintHostInfo(String host) { try { IPHostEntry hostInfo; // Attempt to resolve DNS for given host or address hostInfo = Dns.Resolve(host); //Resolve:-looked up and returns the IP address and host name
  • 14. // Display the primary host name Console.WriteLine(" tCanonical Name : " + hostInfo.HostName); // Display list of IP addresses for this host Console.Write(" tIP Addresses: "); foreach (IPAddress ipaddr in hostInfo.AddressList) { Console.Write(ipaddr.ToString()+""); } Console.WriteLine(" n"); } catch (Exception) { Console.WriteLine(" tUnable to resolve host:"+ host+ "n"); } }
  • 15. static void Main(string[] args) { // Get and print local host info try { Console.WriteLine("Local Host:"); String localHostName = Dns.GetHostName(); Console.WriteLine(" tHost Name: " + localHostName); PrintHostInfo(localHostName); } catch (Exception) { Console.WriteLine("Unable to resolve local hostn"); } } }
  • 16.
  • 17.
  • 18. TCP classes • The transmission control protocol (TCP) classes offer simple methods for connecting and sending data between two endpoints. An endpoint is the combination of an IP address and a port number. • Existing protocols have well defined port numbers, for example, HTTP uses port 80, while SMTP uses port 25. • The Internet Assigned Number Authority (IANA), (http://www.iana.org/) assigns port numbers to these well-known services.
  • 19. • Socket: Low-level class that deals with managing connections. Classes such as WebRequest, TcpClient, and UdpClient use this class internally. • NetworkStream: Derived from Stream. Represents a stream of data from/to the network. • TcpClient: Enables you to create and use TCP connections.
  • 20. • TcpListener: Enables you to listen for incoming TCP connection requests. • The TcpListener class listens for incoming TCP connections with the Start()method. • When a connection request arrives you can use the AcceptSocket() method to return a socket for communication with the remote machine, or use the AcceptTcpClient()method to use a higher-level TcpClient object for communication.
  • 21. • UdpClient: Enables you to create connections for UDP clients. (UDP is an alternative protocol to TCP, but is much less widely used, mostly on local networks.)