SlideShare a Scribd company logo
1 of 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.)

More Related Content

What's hot

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
 

What's hot (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)
 

Similar to 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
 

Similar to 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
 

Recently uploaded

Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024BookNet Canada
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraDeakin University
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Unlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power SystemsUnlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power SystemsPrecisely
 

Recently uploaded (20)

Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptxVulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning era
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Unlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power SystemsUnlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power Systems
 

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.)