Socket Programming
with C#
Windows Socket
• Windows Sockets 2 (Winsock) enables programmers to create advanced
Internet, intranet, and other network-...
Server vs Client
• Server: Listen on a port
• Client: Connect to server
If the server is not “Listening” then client can n...
Server steps
Create a socket.
Bind the socket.
Listen on the socket for a client.
Accept a connection from a client.
Recei...
Client steps
Create a socket.
Connect to the server.
Send and receive data.
Disconnect.
C# socket class
class TcpListener : Listens for connections from TCP network clients.
class TcpClient : Provides client co...
Synchronous and Asynchronous
Many applications call methods asynchronously because it enables the
application to continue ...
Nächste SlideShare
Wird geladen in …5
×

Socket programming in C#

619 Aufrufe

Veröffentlicht am

fundemental of socket programming in C#

Veröffentlicht in: Software
0 Kommentare
1 Gefällt mir
Statistik
Notizen
  • Als Erste(r) kommentieren

Keine Downloads
Aufrufe
Aufrufe insgesamt
619
Auf SlideShare
0
Aus Einbettungen
0
Anzahl an Einbettungen
4
Aktionen
Geteilt
0
Downloads
11
Kommentare
0
Gefällt mir
1
Einbettungen 0
Keine Einbettungen

Keine Notizen für die Folie

Socket programming in C#

  1. 1. Socket Programming with C#
  2. 2. Windows Socket • Windows Sockets 2 (Winsock) enables programmers to create advanced Internet, intranet, and other network-capable applications to transmit application data across the wire, independent of the network protocol being used.
  3. 3. Server vs Client • Server: Listen on a port • Client: Connect to server If the server is not “Listening” then client can not connect to it.
  4. 4. Server steps Create a socket. Bind the socket. Listen on the socket for a client. Accept a connection from a client. Receive and send data. Disconnect.
  5. 5. Client steps Create a socket. Connect to the server. Send and receive data. Disconnect.
  6. 6. C# socket class class TcpListener : Listens for connections from TCP network clients. class TcpClient : Provides client connections for TCP network services. class UdpClient : Provides User Datagram Protocol (UDP) network services. NetworkStream : Provides the underlying stream of data for network access. SocketException The exception that is thrown when a socket error occurs.
  7. 7. Synchronous and Asynchronous Many applications call methods asynchronously because it enables the application to continue doing useful work while the method call runs. An asynchronous client socket does not suspend the application while waiting for network operations to complete. Synchronous call return immediately without waiting for the method to finished.

×