SlideShare a Scribd company logo
1 of 14
Download to read offline
Visual C# .Net using
framework 4.5
Eng. Mahmoud Ouf
Lecture 11
mmouf@2018
Network Architecture
mmouf@2018
Type of Communications
There are two types of communications:
• Connection oriented communications
Which are similar to the telephone system, in which a connection is
established and held for the length of the session
• Connectionless communications
Which are similar to the postal service, in which two letters mailed from
the same place and to the same destination may actually take two different
paths through the system and even arrive at different times
mmouf@2018
Communication Protocols
There are two types of protocols:
• Transmission Control Protocol (TCP)
connection-oriented communication protocol which guarantees that sent
packets will arrive at the intended receiver undamaged and in the correct
sequence.
If packets of information don't arrive at the recipient, TCP ensures that the
packets are sent again.
If the packets arrive out of order, TCP reassembles them in the correct
order transparently to the receiving application.
If duplicate packets arrive, TCP discards them.
mmouf@2018
Communication Protocols
• User Datagram Protocol (UDP)
connectionless communication protocol. It incurs the minimum overhead
necessary to communicate between applications.
UDP makes no guarantees that packets, called datagrams, will reach their
destination or arrive in their original order.
mmouf@2018
Socket Programming
mmouf@2018
Addresses and Ports
To communication with computer or device, computer requires an address.
The Internet uses two addressing systems:
IPv4 (Currently the dominant addressing system)
IPv4 addresses are 32 bits wide.
When string-formatted, IPv4 addresses are written as four dot-separated
decimals (e.g., 101.102.103.104).
An address can be unique in the world or unique within a particular subnet
(such as on a corporate network).
IPv6 (The newer 128-bit addressing system)
Addresses are string-formatted in hexadecimal with a colon separator (e.g.,
[3EA0:FFFF:198A:E4A3:4FF2:54fA:41BC:8D31]).
mmouf@2018
Addresses and Ports
The TCP and UDP protocols break out each IP address into 65,535 ports,
allowing a computer on a single address to run multiple applications, each
on its own port.
Many applications have standard port assignments; for instance, HTTP uses
port 80; SMTP uses port 25.
Ports till 1024 are reserved for the Operating System, So use a port number
above 1024
mmouf@2018
Establishing a Simple TCP Server
This is 5 Steps Process:
1) Create an object of class TcpListner, which represents a TCP stream
socket through which a server can listen for requests
TcpListner server = new TcpListner(localaddr, port);
Where:
localaddr : is the local address of the Server, object from IPAddress
byte []bt = new byte[]{127,0,0,1};
IPAddress localaddr = new IPAddress(bt);
port : bind the server application to a specific port. Number above 1024
mmouf@2018
Establishing a Simple TCP Server
2) Call TcpListner’s Start method, which makes the TcpListner object
begins to listen for connection request.
The Server creates a connection to the client when it receives a
connection request. This is done by calling TcpListner’s AcceptSocket
method which return object of class Socket that is used to manage a
connection to client
server.Start();
Socket connection = server.AcceptSocket();
3) Establish the stream used for communication with the client.
This is done by creating a NetworkStream object that uses the Socket
object representing the connection to perform the actual sending and
receiving data.
NetworkStream nStream = new NetworkStream(connection);
mmouf@2018
Establishing a Simple TCP Server
4) Process the data between server/client using (ReadByte/WriteByte), or
use BinaryReader and BinaryWriter objects.
BinaryReader br = new BinaryReader(nStream);
5) Terminating connection, this is done when the client and server finish
communication, the server calls method Close of BinaryReader,
BinaryWriter, NetworkStream and Socket to terminate the connection. The
server then returns to step two to wait for the next connection request.
Note: it is recommended to call method Shutdown before method Close to
ensure that all data is sent and received before the Socket closes.
br.Close();
nStream.Close();
connection.Shutdown();
connection.Close();
mmouf@2018
Establishing a Simple TCP Client
This is 4 Steps Process:
1) Create an object of class TcpClient to connect to the server. The
connection is established by calling TcpClient method Connect.
One overloaded version of this method takes two arguments the server's
IP address and its port number as in:
TcpClient client = new TcpClient();
client.Connect( serverAddress, serverPort );
If the connection is successful, TcpClient method Connect returns a
positive integer; otherwise, it returns 0.
mmouf@2018
Establishing a Simple TCP Client
2) The TcpClient uses its GetStream method to get a NetworkStream so that
it can write to and read from the server.
We then use the NetworkStream object to create a BinaryWriter and a
BinaryReader that will be used to send information to and receive
information from the server, respectively.
NetworkStream nStream = client.GetStream();
BinaryReader br = new BinaryReader(nStream);
3) The processing phase, in which the client and the server communicate. In
this phase, the client uses BinaryWriter method Write and BinaryReader
method ReadString to perform the appropriate communications.
mmouf@2018
Establishing a Simple TCP Client
4) After the transmission is complete, the client have to close the connection
by calling method Close on each of BinaryReader, BinaryWriter,
NetworkStream and TcpClient. This closes each of the streams and the
TcpClient's Socket to terminate the connection with the server.
br.Close();
nStream.Close();
mmouf@2018

More Related Content

What's hot

Cs8792 cns - unit v
Cs8792   cns - unit vCs8792   cns - unit v
Cs8792 cns - unit vArthyR3
 
Introduction to Cryptography
Introduction to CryptographyIntroduction to Cryptography
Introduction to CryptographyKishansinh Rathod
 
RabbitMQ interview Questions and Answers
RabbitMQ interview Questions and AnswersRabbitMQ interview Questions and Answers
RabbitMQ interview Questions and Answersjeetendra mandal
 
Cs8792 cns - unit i
Cs8792   cns - unit iCs8792   cns - unit i
Cs8792 cns - unit iArthyR3
 
Encryption presentation final
Encryption presentation finalEncryption presentation final
Encryption presentation finaladrigee12
 
Bitcoin Addresses
Bitcoin AddressesBitcoin Addresses
Bitcoin Addressesashmoran
 
Cryptography.ppt
Cryptography.pptCryptography.ppt
Cryptography.pptUday Meena
 
18CS2005 Cryptography and Network Security
18CS2005 Cryptography and Network Security18CS2005 Cryptography and Network Security
18CS2005 Cryptography and Network SecurityKathirvel Ayyaswamy
 
Network security and cryptography
Network security and cryptographyNetwork security and cryptography
Network security and cryptographyRajKumar Rampelli
 
An Introduction to the Message Queuing Technology & IBM WebSphere MQ
An Introduction to the Message Queuing Technology & IBM WebSphere MQAn Introduction to the Message Queuing Technology & IBM WebSphere MQ
An Introduction to the Message Queuing Technology & IBM WebSphere MQRavi Yogesh
 
Data encryption standard DES & 3DES
Data encryption standard DES & 3DESData encryption standard DES & 3DES
Data encryption standard DES & 3DESLaís Berlatto
 

What's hot (20)

Cryptography
CryptographyCryptography
Cryptography
 
WebSphere MQ introduction
WebSphere MQ introductionWebSphere MQ introduction
WebSphere MQ introduction
 
Cs8792 cns - unit v
Cs8792   cns - unit vCs8792   cns - unit v
Cs8792 cns - unit v
 
Introduction to Cryptography
Introduction to CryptographyIntroduction to Cryptography
Introduction to Cryptography
 
RabbitMQ interview Questions and Answers
RabbitMQ interview Questions and AnswersRabbitMQ interview Questions and Answers
RabbitMQ interview Questions and Answers
 
Cs8792 cns - unit i
Cs8792   cns - unit iCs8792   cns - unit i
Cs8792 cns - unit i
 
Overview of cryptography
Overview of cryptographyOverview of cryptography
Overview of cryptography
 
Encryption presentation final
Encryption presentation finalEncryption presentation final
Encryption presentation final
 
Email security
Email securityEmail security
Email security
 
Bitcoin Addresses
Bitcoin AddressesBitcoin Addresses
Bitcoin Addresses
 
Ip security
Ip security Ip security
Ip security
 
Cryptography
CryptographyCryptography
Cryptography
 
Crytography
CrytographyCrytography
Crytography
 
Digital signature
Digital signatureDigital signature
Digital signature
 
Cryptography.ppt
Cryptography.pptCryptography.ppt
Cryptography.ppt
 
18CS2005 Cryptography and Network Security
18CS2005 Cryptography and Network Security18CS2005 Cryptography and Network Security
18CS2005 Cryptography and Network Security
 
Network security and cryptography
Network security and cryptographyNetwork security and cryptography
Network security and cryptography
 
An Introduction to the Message Queuing Technology & IBM WebSphere MQ
An Introduction to the Message Queuing Technology & IBM WebSphere MQAn Introduction to the Message Queuing Technology & IBM WebSphere MQ
An Introduction to the Message Queuing Technology & IBM WebSphere MQ
 
Introduction to Cryptography
Introduction to CryptographyIntroduction to Cryptography
Introduction to Cryptography
 
Data encryption standard DES & 3DES
Data encryption standard DES & 3DESData encryption standard DES & 3DES
Data encryption standard DES & 3DES
 

Similar to Intake 38 11

TCP/IP 3-way Handshake
TCP/IP 3-way Handshake TCP/IP 3-way Handshake
TCP/IP 3-way Handshake Alok Tripathi
 
Transport Layer [Autosaved]
Transport Layer [Autosaved]Transport Layer [Autosaved]
Transport Layer [Autosaved]Ram Dutt Shukla
 
13_TCP_Attack.pptx
13_TCP_Attack.pptx13_TCP_Attack.pptx
13_TCP_Attack.pptxAlmaOraevi
 
Network protocols
Network protocolsNetwork protocols
Network protocolsAbiud Orina
 
tcp-ippresentation-150614172243-lva1-app6892.pptx
tcp-ippresentation-150614172243-lva1-app6892.pptxtcp-ippresentation-150614172243-lva1-app6892.pptx
tcp-ippresentation-150614172243-lva1-app6892.pptxAlphaKoiSylvester
 
TCP - IP Presentation
TCP - IP PresentationTCP - IP Presentation
TCP - IP PresentationHarish Chand
 
CCNA (R & S) Module 01 - Introduction to Networks - Chapter 9
CCNA (R & S) Module 01 - Introduction to Networks - Chapter 9CCNA (R & S) Module 01 - Introduction to Networks - Chapter 9
CCNA (R & S) Module 01 - Introduction to Networks - Chapter 9Waqas Ahmed Nawaz
 
Transport Layer Services : Multiplexing And Demultiplexing
Transport Layer Services : Multiplexing And DemultiplexingTransport Layer Services : Multiplexing And Demultiplexing
Transport Layer Services : Multiplexing And DemultiplexingKeyur Vadodariya
 
Unit 4-Transport Layer Protocols-3.pptx
Unit 4-Transport Layer Protocols-3.pptxUnit 4-Transport Layer Protocols-3.pptx
Unit 4-Transport Layer Protocols-3.pptxDESTROYER39
 
Unit 4-Transport Layer Protocols.pptx
Unit 4-Transport Layer Protocols.pptxUnit 4-Transport Layer Protocols.pptx
Unit 4-Transport Layer Protocols.pptxsarosh32
 

Similar to Intake 38 11 (20)

Intake 37 12
Intake 37 12Intake 37 12
Intake 37 12
 
Networking in python by Rj
Networking in python by RjNetworking in python by Rj
Networking in python by Rj
 
TCP/IP 3-way Handshake
TCP/IP 3-way Handshake TCP/IP 3-way Handshake
TCP/IP 3-way Handshake
 
TCP/IP Basics
TCP/IP BasicsTCP/IP Basics
TCP/IP Basics
 
Tcp3 wayhandshakeprocess
Tcp3 wayhandshakeprocessTcp3 wayhandshakeprocess
Tcp3 wayhandshakeprocess
 
Transport Layer
Transport LayerTransport Layer
Transport Layer
 
Transport Layer [Autosaved]
Transport Layer [Autosaved]Transport Layer [Autosaved]
Transport Layer [Autosaved]
 
13_TCP_Attack.pptx
13_TCP_Attack.pptx13_TCP_Attack.pptx
13_TCP_Attack.pptx
 
Network protocols
Network protocolsNetwork protocols
Network protocols
 
tcp-ippresentation-150614172243-lva1-app6892.pptx
tcp-ippresentation-150614172243-lva1-app6892.pptxtcp-ippresentation-150614172243-lva1-app6892.pptx
tcp-ippresentation-150614172243-lva1-app6892.pptx
 
TCP - IP Presentation
TCP - IP PresentationTCP - IP Presentation
TCP - IP Presentation
 
Tcp ip presentation
Tcp ip presentationTcp ip presentation
Tcp ip presentation
 
Lecture set 7
Lecture set 7Lecture set 7
Lecture set 7
 
CCNA (R & S) Module 01 - Introduction to Networks - Chapter 9
CCNA (R & S) Module 01 - Introduction to Networks - Chapter 9CCNA (R & S) Module 01 - Introduction to Networks - Chapter 9
CCNA (R & S) Module 01 - Introduction to Networks - Chapter 9
 
Transport Layer Services : Multiplexing And Demultiplexing
Transport Layer Services : Multiplexing And DemultiplexingTransport Layer Services : Multiplexing And Demultiplexing
Transport Layer Services : Multiplexing And Demultiplexing
 
Md13 networking
Md13 networkingMd13 networking
Md13 networking
 
TCP /IP
TCP /IPTCP /IP
TCP /IP
 
Tcp presentation
Tcp presentationTcp presentation
Tcp presentation
 
Unit 4-Transport Layer Protocols-3.pptx
Unit 4-Transport Layer Protocols-3.pptxUnit 4-Transport Layer Protocols-3.pptx
Unit 4-Transport Layer Protocols-3.pptx
 
Unit 4-Transport Layer Protocols.pptx
Unit 4-Transport Layer Protocols.pptxUnit 4-Transport Layer Protocols.pptx
Unit 4-Transport Layer Protocols.pptx
 

More from Mahmoud Ouf

More from Mahmoud Ouf (20)

Relation between classes in arabic
Relation between classes in arabicRelation between classes in arabic
Relation between classes in arabic
 
Intake 38 data access 5
Intake 38 data access 5Intake 38 data access 5
Intake 38 data access 5
 
Intake 38 data access 4
Intake 38 data access 4Intake 38 data access 4
Intake 38 data access 4
 
Intake 38 data access 3
Intake 38 data access 3Intake 38 data access 3
Intake 38 data access 3
 
Intake 38 data access 1
Intake 38 data access 1Intake 38 data access 1
Intake 38 data access 1
 
Intake 38 12
Intake 38 12Intake 38 12
Intake 38 12
 
Intake 38 10
Intake 38 10Intake 38 10
Intake 38 10
 
Intake 38 9
Intake 38 9Intake 38 9
Intake 38 9
 
Intake 38 8
Intake 38 8Intake 38 8
Intake 38 8
 
Intake 38 7
Intake 38 7Intake 38 7
Intake 38 7
 
Intake 38 6
Intake 38 6Intake 38 6
Intake 38 6
 
Intake 38 5 1
Intake 38 5 1Intake 38 5 1
Intake 38 5 1
 
Intake 38 5
Intake 38 5Intake 38 5
Intake 38 5
 
Intake 38 4
Intake 38 4Intake 38 4
Intake 38 4
 
Intake 38 3
Intake 38 3Intake 38 3
Intake 38 3
 
Intake 38 2
Intake 38 2Intake 38 2
Intake 38 2
 
Intake 38_1
Intake 38_1Intake 38_1
Intake 38_1
 
Intake 37 DM
Intake 37 DMIntake 37 DM
Intake 37 DM
 
Intake 37 ef2
Intake 37 ef2Intake 37 ef2
Intake 37 ef2
 
Intake 37 ef1
Intake 37 ef1Intake 37 ef1
Intake 37 ef1
 

Recently uploaded

BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...Sapna Thakur
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...PsychoTech Services
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room servicediscovermytutordmt
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhikauryashika82
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpinRaunakKeshri1
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...christianmathematics
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Disha Kariya
 
General AI for Medical Educators April 2024
General AI for Medical Educators April 2024General AI for Medical Educators April 2024
General AI for Medical Educators April 2024Janet Corral
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...fonyou31
 

Recently uploaded (20)

BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room service
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpin
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
General AI for Medical Educators April 2024
General AI for Medical Educators April 2024General AI for Medical Educators April 2024
General AI for Medical Educators April 2024
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
 

Intake 38 11

  • 1. Visual C# .Net using framework 4.5 Eng. Mahmoud Ouf Lecture 11 mmouf@2018
  • 3. Type of Communications There are two types of communications: • Connection oriented communications Which are similar to the telephone system, in which a connection is established and held for the length of the session • Connectionless communications Which are similar to the postal service, in which two letters mailed from the same place and to the same destination may actually take two different paths through the system and even arrive at different times mmouf@2018
  • 4. Communication Protocols There are two types of protocols: • Transmission Control Protocol (TCP) connection-oriented communication protocol which guarantees that sent packets will arrive at the intended receiver undamaged and in the correct sequence. If packets of information don't arrive at the recipient, TCP ensures that the packets are sent again. If the packets arrive out of order, TCP reassembles them in the correct order transparently to the receiving application. If duplicate packets arrive, TCP discards them. mmouf@2018
  • 5. Communication Protocols • User Datagram Protocol (UDP) connectionless communication protocol. It incurs the minimum overhead necessary to communicate between applications. UDP makes no guarantees that packets, called datagrams, will reach their destination or arrive in their original order. mmouf@2018
  • 7. Addresses and Ports To communication with computer or device, computer requires an address. The Internet uses two addressing systems: IPv4 (Currently the dominant addressing system) IPv4 addresses are 32 bits wide. When string-formatted, IPv4 addresses are written as four dot-separated decimals (e.g., 101.102.103.104). An address can be unique in the world or unique within a particular subnet (such as on a corporate network). IPv6 (The newer 128-bit addressing system) Addresses are string-formatted in hexadecimal with a colon separator (e.g., [3EA0:FFFF:198A:E4A3:4FF2:54fA:41BC:8D31]). mmouf@2018
  • 8. Addresses and Ports The TCP and UDP protocols break out each IP address into 65,535 ports, allowing a computer on a single address to run multiple applications, each on its own port. Many applications have standard port assignments; for instance, HTTP uses port 80; SMTP uses port 25. Ports till 1024 are reserved for the Operating System, So use a port number above 1024 mmouf@2018
  • 9. Establishing a Simple TCP Server This is 5 Steps Process: 1) Create an object of class TcpListner, which represents a TCP stream socket through which a server can listen for requests TcpListner server = new TcpListner(localaddr, port); Where: localaddr : is the local address of the Server, object from IPAddress byte []bt = new byte[]{127,0,0,1}; IPAddress localaddr = new IPAddress(bt); port : bind the server application to a specific port. Number above 1024 mmouf@2018
  • 10. Establishing a Simple TCP Server 2) Call TcpListner’s Start method, which makes the TcpListner object begins to listen for connection request. The Server creates a connection to the client when it receives a connection request. This is done by calling TcpListner’s AcceptSocket method which return object of class Socket that is used to manage a connection to client server.Start(); Socket connection = server.AcceptSocket(); 3) Establish the stream used for communication with the client. This is done by creating a NetworkStream object that uses the Socket object representing the connection to perform the actual sending and receiving data. NetworkStream nStream = new NetworkStream(connection); mmouf@2018
  • 11. Establishing a Simple TCP Server 4) Process the data between server/client using (ReadByte/WriteByte), or use BinaryReader and BinaryWriter objects. BinaryReader br = new BinaryReader(nStream); 5) Terminating connection, this is done when the client and server finish communication, the server calls method Close of BinaryReader, BinaryWriter, NetworkStream and Socket to terminate the connection. The server then returns to step two to wait for the next connection request. Note: it is recommended to call method Shutdown before method Close to ensure that all data is sent and received before the Socket closes. br.Close(); nStream.Close(); connection.Shutdown(); connection.Close(); mmouf@2018
  • 12. Establishing a Simple TCP Client This is 4 Steps Process: 1) Create an object of class TcpClient to connect to the server. The connection is established by calling TcpClient method Connect. One overloaded version of this method takes two arguments the server's IP address and its port number as in: TcpClient client = new TcpClient(); client.Connect( serverAddress, serverPort ); If the connection is successful, TcpClient method Connect returns a positive integer; otherwise, it returns 0. mmouf@2018
  • 13. Establishing a Simple TCP Client 2) The TcpClient uses its GetStream method to get a NetworkStream so that it can write to and read from the server. We then use the NetworkStream object to create a BinaryWriter and a BinaryReader that will be used to send information to and receive information from the server, respectively. NetworkStream nStream = client.GetStream(); BinaryReader br = new BinaryReader(nStream); 3) The processing phase, in which the client and the server communicate. In this phase, the client uses BinaryWriter method Write and BinaryReader method ReadString to perform the appropriate communications. mmouf@2018
  • 14. Establishing a Simple TCP Client 4) After the transmission is complete, the client have to close the connection by calling method Close on each of BinaryReader, BinaryWriter, NetworkStream and TcpClient. This closes each of the streams and the TcpClient's Socket to terminate the connection with the server. br.Close(); nStream.Close(); mmouf@2018