SlideShare ist ein Scribd-Unternehmen logo
1 von 12
Using The CSharp Sockets Helper Classes
Using The CSharp Sockets Helper Classes
Using The CSharp Sockets Helper Classes
Using The CSharp Sockets Helper Classes
Using The CSharp Sockets Helper Classes
Using The CSharp Sockets Helper Classes
Using The CSharp Sockets Helper Classes
Using The CSharp Sockets Helper Classes
Using The CSharp Sockets Helper Classes
Using The CSharp Sockets Helper Classes
Using The CSharp Sockets Helper Classes
Using The CSharp Sockets Helper Classes

Weitere ähnliche Inhalte

Andere mochten auch

2013캄보디아
2013캄보디아2013캄보디아
2013캄보디아christmh
 
Diabetes Health Reminders
Diabetes Health RemindersDiabetes Health Reminders
Diabetes Health Remindersdrglasgow2013
 
Network Programming in C#
Network Programming in C#Network Programming in C#
Network Programming in C#jvinhit
 
Amelia earhart project 7
Amelia earhart project 7Amelia earhart project 7
Amelia earhart project 7lexief23
 
myoStream Presentation
myoStream PresentationmyoStream Presentation
myoStream Presentationmyostream
 
Store procedure
Store procedureStore procedure
Store procedurejvinhit
 
Xử lý ảnh
Xử lý ảnhXử lý ảnh
Xử lý ảnhjvinhit
 
Delegate và event trong C#
Delegate và event trong C#Delegate và event trong C#
Delegate và event trong C#jvinhit
 

Andere mochten auch (10)

2013캄보디아
2013캄보디아2013캄보디아
2013캄보디아
 
Diabetes Health Reminders
Diabetes Health RemindersDiabetes Health Reminders
Diabetes Health Reminders
 
Network Programming in C#
Network Programming in C#Network Programming in C#
Network Programming in C#
 
Vemma
VemmaVemma
Vemma
 
Amelia earhart project 7
Amelia earhart project 7Amelia earhart project 7
Amelia earhart project 7
 
myoStream Presentation
myoStream PresentationmyoStream Presentation
myoStream Presentation
 
Store procedure
Store procedureStore procedure
Store procedure
 
Xử lý ảnh
Xử lý ảnhXử lý ảnh
Xử lý ảnh
 
Delegate và event trong C#
Delegate và event trong C#Delegate và event trong C#
Delegate và event trong C#
 
Yourprezi
YourpreziYourprezi
Yourprezi
 

Kürzlich hochgeladen

Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rick Flair
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 
What is Artificial Intelligence?????????
What is Artificial Intelligence?????????What is Artificial Intelligence?????????
What is Artificial Intelligence?????????blackmambaettijean
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demoHarshalMandlekar2
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embeddingZilliz
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersNicole Novielli
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 

Kürzlich hochgeladen (20)

Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 
What is Artificial Intelligence?????????
What is Artificial Intelligence?????????What is Artificial Intelligence?????????
What is Artificial Intelligence?????????
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demo
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embedding
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software Developers
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 

Hinweis der Redaktion

  1. Chương trình sẽ chặn lại ở phương thức AcceptTcpClient() và chờ đợi một kết nối mới từ Client. Một khi đã kết nối rồi thì bạn sử dụng phương thức GetStream() để tạo ra một NetworkStream thực thi cho việc gửi và nhận dữ liệu trên Socket. _Lưu ý:Ta luôn luôn phải đóng NetworkStream khi xong việc như là bạn nhớ phải đóng đối tượng TcpClient khi chúng ta hoàn thành.Bạn cũng phải đóng TcpListener bằng phương thức Stop(). _Quy tắc gửi và nhận dữ liệu bạn xem lại phần trước: TcpClient. Các phương thức và thuộc tính của lớp TcpListener các bạn có thể tra cứu trong MSDN. ANY : Cung cap mot dia chi IP de chi ra rang Server phai lang nghe tren tat ca cac card mang Nguyên tắc gửi và nhận dữ liệu: _Nguyên tắc chung: Dữ liệu từ dạng String cần phải chuyển thành mảng byte trước khi được chuyển đi, vì theo nguyên lý mạng máy tính thì trên đường truyền vật lý sẽ chỉ gửi các dữ liệu dạng bit: 0 or 1. Code: string StrData="Chao Server."; byte[] data= new byte[1024]; ...... data = Encoding.ASCII.GetBytes(StrData); .....//Gửi dữ liệu đi. Khi nhận dữ liệu thì cần phải chuyển byte đó lại thành dạng String để sau đó hiển thị ra màn hình. Code: byte[] data = new byte[1024]; String Input=""; ........//Nhận dữ liệu Input= Encoding.ASCII.GetString(data,0,data.Length); Console.WriteLine(input);
  2. De tao ra mot socket : Chương trình sẽ chặn lại ở phương thức AcceptTcpClient() và chờ đợi một kết nối mới từ Client. Một khi đã kết nối rồi thì bạn sử dụng phương thức GetStream() để tạo ra một NetworkStream thực thi cho việc gửi và nhận dữ liệu trên Socket. _Lưu ý:Ta luôn luôn phải đóng NetworkStream khi xong việc như là bạn nhớ phải đóng đối tượng TcpClient khi chúng ta hoàn thành.Bạn cũng phải đóng TcpListener bằng phương thức Stop(). _Quy tắc gửi và nhận dữ liệu bạn xem lại phần trước: TcpClient. Các phương thức và thuộc tính của lớp TcpListener các bạn có thể tra cứu trong MSDN. ANY : Cung cap mot dia chi IP de chi ra rang Server phai lang nghe tren tat ca cac card mang Nguyên tắc gửi và nhận dữ liệu: _Nguyên tắc chung: Dữ liệu từ dạng String cần phải chuyển thành mảng byte trước khi được chuyển đi, vì theo nguyên lý mạng máy tính thì trên đường truyền vật lý sẽ chỉ gửi các dữ liệu dạng bit: 0 or 1. Code: string StrData="Chao Server."; byte[] data= new byte[1024]; ...... data = Encoding.ASCII.GetBytes(StrData); .....//Gửi dữ liệu đi. Khi nhận dữ liệu thì cần phải chuyển byte đó lại thành dạng String để sau đó hiển thị ra màn hình. Code: byte[] data = new byte[1024]; String Input=""; ........//Nhận dữ liệu Input= Encoding.ASCII.GetString(data,0,data.Length); Console.WriteLine(input);
  3. Khi một đối tượng TcpListener được tạo ra thì bạn có thể bắt đầu lắng nghe các kết nối, sử dụng phương thức Start(). _Sau phương thức Start(), bạn phải sử dụng 1 trong 2 phương thức AcceptSocket() hoặc AcceptTcpClient() để chấp nhận các kết nối. Như bạn nhìn thấy, có 2 phương thức chấp nhận các kết nối và trả về 1 đối tượng Socket hoặc TcpClient. Chương trình sẽ chặn lại ở phương thức AcceptTcpClient() và chờ đợi một kết nối mới từ Client. Một khi đã kết nối rồi thì bạn sử dụng phương thức GetStream() để tạo ra một NetworkStream thực thi cho việc gửi và nhận dữ liệu trên Socket. _Lưu ý:Ta luôn luôn phải đóng NetworkStream khi xong việc như là bạn nhớ phải đóng đối tượng TcpClient khi chúng ta hoàn thành.Bạn cũng phải đóng TcpListener bằng phương thức Stop(). _Quy tắc gửi và nhận dữ liệu bạn xem lại phần trước: TcpClient. Các phương thức và thuộc tính của lớp TcpListener các bạn có thể tra cứu trong MSDN. ANY : Cung cap mot dia chi IP de chi ra rang Server phai lang nghe tren tat ca cac card mang Nguyên tắc gửi và nhận dữ liệu: _Nguyên tắc chung: Dữ liệu từ dạng String cần phải chuyển thành mảng byte trước khi được chuyển đi, vì theo nguyên lý mạng máy tính thì trên đường truyền vật lý sẽ chỉ gửi các dữ liệu dạng bit: 0 or 1. Code: string StrData="Chao Server."; byte[] data= new byte[1024]; ...... data = Encoding.ASCII.GetBytes(StrData); .....//Gửi dữ liệu đi. Khi nhận dữ liệu thì cần phải chuyển byte đó lại thành dạng String để sau đó hiển thị ra màn hình. Code: byte[] data = new byte[1024]; String Input=""; ........//Nhận dữ liệu Input= Encoding.ASCII.GetString(data,0,data.Length); Console.WriteLine(input);
  4. Khi một đối tượng TcpListener được tạo ra thì bạn có thể bắt đầu lắng nghe các kết nối, sử dụng phương thức Start(). _Sau phương thức Start(), bạn phải sử dụng 1 trong 2 phương thức AcceptSocket() hoặc AcceptTcpClient() để chấp nhận các kết nối. Như bạn nhìn thấy, có 2 phương thức chấp nhận các kết nối và trả về 1 đối tượng Socket hoặc TcpClient. . Chương trình sẽ chặn lại ở phương thức AcceptTcpClient() và chờ đợi một kết nối mới từ Client. Một khi đã kết nối rồi thì bạn sử dụng phương thức GetStream() để tạo ra một NetworkStream thực thi cho việc gửi và nhận dữ liệu trên Socket. _Lưu ý:Ta luôn luôn phải đóng NetworkStream khi xong việc như là bạn nhớ phải đóng đối tượng TcpClient khi chúng ta hoàn thành.Bạn cũng phải đóng TcpListener bằng phương thức Stop(). _Quy tắc gửi và nhận dữ liệu bạn xem lại phần trước: TcpClient. Các phương thức và thuộc tính của lớp TcpListener các bạn có thể tra cứu trong MSDN. ANY : Cung cap mot dia chi IP de chi ra rang Server phai lang nghe tren tat ca cac card mang Nguyên tắc gửi và nhận dữ liệu: _Nguyên tắc chung: Dữ liệu từ dạng String cần phải chuyển thành mảng byte trước khi được chuyển đi, vì theo nguyên lý mạng máy tính thì trên đường truyền vật lý sẽ chỉ gửi các dữ liệu dạng bit: 0 or 1. Code: string StrData="Chao Server."; byte[] data= new byte[1024]; ...... data = Encoding.ASCII.GetBytes(StrData); .....//Gửi dữ liệu đi. Khi nhận dữ liệu thì cần phải chuyển byte đó lại thành dạng String để sau đó hiển thị ra màn hình. Code: byte[] data = new byte[1024]; String Input=""; ........//Nhận dữ liệu Input= Encoding.ASCII.GetString(data,0,data.Length); Console.WriteLine(input);
  5. ANY : Cung cap mot dia chi IP de chi ra rang Server phai lang nghe tren tat ca cac card mang Nguyên tắc gửi và nhận dữ liệu: _Nguyên tắc chung: Dữ liệu từ dạng String cần phải chuyển thành mảng byte trước khi được chuyển đi, vì theo nguyên lý mạng máy tính thì trên đường truyền vật lý sẽ chỉ gửi các dữ liệu dạng bit: 0 or 1. Code: string StrData="Chao Server."; byte[] data= new byte[1024]; ...... data = Encoding.ASCII.GetBytes(StrData); .....//Gửi dữ liệu đi. Khi nhận dữ liệu thì cần phải chuyển byte đó lại thành dạng String để sau đó hiển thị ra màn hình. Code: byte[] data = new byte[1024]; String Input=""; ........//Nhận dữ liệu Input= Encoding.ASCII.GetString(data,0,data.Length); Console.WriteLine(input);
  6. ANY : Cung cap mot dia chi IP de chi ra rang Server phai lang nghe tren tat ca cac card mang Nguyên tắc gửi và nhận dữ liệu: _Nguyên tắc chung: Dữ liệu từ dạng String cần phải chuyển thành mảng byte trước khi được chuyển đi, vì theo nguyên lý mạng máy tính thì trên đường truyền vật lý sẽ chỉ gửi các dữ liệu dạng bit: 0 or 1. Code: string StrData="Chao Server."; byte[] data= new byte[1024]; ...... data = Encoding.ASCII.GetBytes(StrData); .....//Gửi dữ liệu đi. Khi nhận dữ liệu thì cần phải chuyển byte đó lại thành dạng String để sau đó hiển thị ra màn hình. Code: byte[] data = new byte[1024]; String Input=""; ........//Nhận dữ liệu Input= Encoding.ASCII.GetString(data,0,data.Length); Console.WriteLine(input);
  7. ANY : Cung cap mot dia chi IP de chi ra rang Server phai lang nghe tren tat ca cac card mang Nguyên tắc gửi và nhận dữ liệu: _Nguyên tắc chung: Dữ liệu từ dạng String cần phải chuyển thành mảng byte trước khi được chuyển đi, vì theo nguyên lý mạng máy tính thì trên đường truyền vật lý sẽ chỉ gửi các dữ liệu dạng bit: 0 or 1. Code: string StrData="Chao Server."; byte[] data= new byte[1024]; ...... data = Encoding.ASCII.GetBytes(StrData); .....//Gửi dữ liệu đi. Khi nhận dữ liệu thì cần phải chuyển byte đó lại thành dạng String để sau đó hiển thị ra màn hình. Code: byte[] data = new byte[1024]; String Input=""; ........//Nhận dữ liệu Input= Encoding.ASCII.GetString(data,0,data.Length); Console.WriteLine(input); Phuong thuc send co 3 phuong dang : Neu Udpclient ket noi voi 1 host o xa thi send() ko can chi dinh dich cua du lieu + nguoc lai thi phai ch idinh dich