• 검색 결과가 없습니다.

Socket Programming Laboratory - 03

N/A
N/A
Protected

Academic year: 2021

Share "Socket Programming Laboratory - 03"

Copied!
15
0
0

로드 중.... (전체 텍스트 보기)

전체 글

(1)

Socket Programming

Laboratory - 03

(2)

Socket class

provides a rich set of methods and properties for network communications. The Socket class allows you to perform both synchronous and

asynchronous data transfer using any of the communication protocols listed in

the ProtocolType enumeration.

AddressFamily

Specifies the addressing scheme that an instance of the Socket class can use. (i.e. InterNetwork for IPv4 address, InterNetworkV6 for IPv6 address,

etc.)

Socket Class

(3)

SocketType Enumeration

Specifies the type of socket an instance of the Socket class represents.

SocketType will sometimes implicitly indicate

which ProtocolType will be used within an AddressFamily.

For example, when theSocketType is Dgram, the ProtocolType is always UDP. When

the SocketType is Stream, the ProtocolType is always TCP. If you try to create a Socket with an incompatible combination, Socket will throw

a SocketException.

ProtocolType Enumeration

Specifies the protocols that the Socket class supports. For example, IP, TCP, IPv6, etc.

Socket Class

(4)

IPEndPoint Class

Represents a network endpoint as an IP address and a port number.

IPEndPoint Class

(5)

Echo server and echo client are the socket programming equivalence of Hello World program found in typical programming

example. The main objective of echo server is to reply back (echo) the same message sent by client.

Download and Run the program

Echo Server & Echo Client

(6)

Modify the echo server program that will reply back the same sent by client but in uppercase.

Exercise - 1

(7)

Big-endian to Little-endian

Big-endian – Most significant byte first

Little-endian – Least significant byte first

To convert an IP address to integer, break it into four octets. For example:

Byte Ordering

(8)

Big-endian

IP uses big-endian in network, also known as network order

Little-endian

Host system running on windows operating system uses little-endian

Therefore, we need to convert from big- endian to little-endian

Why need to Convert?

(9)

IPEndPoint Class

Represents a network endpoint as an IP address and a port number.

IPAddress.HostToNetworkOrder Method

Converts a value from host byte order to network byte order.

Pnt.Address

Gets or sets the IP address of the endpoint.

Example (LongEndPoint.cs)

(10)

Write a program that will convert from little- endian to big-endian.

Exercise - 2

(11)

Example: HostIP.cs

Dns.GetHostName() Method

Gets the host name of the local computer

Dns.GetHostEntry(String)

Resolves a host name or IP address to an IPHostEntry instance.

Host IP address

(12)

A machine could have several IP addresses.

Write a program that will display your own IP address.

Exercise - 3

(13)

Get IP addresses from Domain Name.

IPLookup.cs

(14)

WelcomeServer.cs

WelcomeClient.cs

Getting client’s IP

addresses

(15)

Modify the WelcomeClient.cs program that client will look for (search) the server IP

address and get connected.

Exercise - 4

참조

관련 문서

„ Process rank (in range 0, 1, …, p-1) returned through second argument.

The purpose of this study is to investigate the effect of the “problem solving and programming” area of ​​information subject on perception and

Penalty Function Method, Sequential Linear Programming, Constrained Steepest Descent Method, Method of Feasible Directions(MFD), Sequential Quadratic Programming(SQP), etc.

- 이 class에서 가시화를 담당하는 함수는 RenderScene() 함수이다. 이를 위해 OpenGLVeiw class에서는.. 이를 위해서는 CColorDialog class를 이용해야

Bspline classs ... BsplineSurface classs ... CASDMFCDoc class ... OpenGLVeiw class .... 따라서 curve와는 달리, surface는 Cox-de Boor recurrence formula를 적용핛

The rationale for augmentation of the residual alveolar socket at the time of tooth removal such as socket reservation, socket augmentation and ridge

Understanding assembly code and how it relates to the original C code is a key step in understanding how computers execute

auto double int struct break else long switch case enum register typedef char extern return union const float short unsigned continue for signed void.. default