0% found this document useful (0 votes)
105 views9 pages

Class Namespace Desciption

The document describes the basic classes needed for network programming in .NET and the steps to create a basic TCP/IP client-server connection. It lists classes like IPAddress, IPEndPoint, Socket, and MemoryStream that are in the System.Net and System.IO namespaces. It then outlines the steps the server takes to listen on a port and accept connections and the steps the client takes to connect, send, and receive data from the server. Both the server and client use serialization with MemoryStream and BinaryFormatter to convert data between string and byte formats when sending messages.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
105 views9 pages

Class Namespace Desciption

The document describes the basic classes needed for network programming in .NET and the steps to create a basic TCP/IP client-server connection. It lists classes like IPAddress, IPEndPoint, Socket, and MemoryStream that are in the System.Net and System.IO namespaces. It then outlines the steps the server takes to listen on a port and accept connections and the steps the client takes to connect, send, and receive data from the server. Both the server and client use serialization with MemoryStream and BinaryFormatter to convert data between string and byte formats when sending messages.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 9

Basic .

Net classes in Network Programming


Class Namespace Desciption
IPAddress System.Net Provides an Internet Protocol (IP) address.
Represents a network endpoint as an IP address and
IPEndPoint System.Net
a port number.
System.Net.Socket
Socket Implements the Berkeley sockets interface.
s
Provides the underlying stream of data for network
MemoryStream System.IO
access.
Creates and controls a thread, sets its priority, and
Thread System.Threading
gets its status.

Server-Client connection with TCP/IP


When the application is run, the server needs to be identified with an IP address and will
"listen" on a specific port. The server will stay in this state until the client sends a connection
request. Once accepted by the server, a connection is formed allowing the server and client to
communicate with each other.
More specifically, the steps on the server and the client that we need to perform using the
TCP/IP protocol in C# (can run server and client on the same machine):

SERVER:
1. Create a System.Net.Sockets.Socket object to start "listening" on a local port.
2. Wait and accept the connection from the client with the Accept () method. This method
returns a System.Net.Sockets.Socket object used to send and receive data.

3. Events btnStart_Click to start Server.


4. Send message to all clients by Send() method

5. Serialize() create a MemoryStream object to send message to all clients by using


BinaryFormatter object to convert Sting datatype to byte datatype.

6. Events btnSend_Click to execute Send() method.


7. Receive message from a client and send to others.

8. Deserialize() method to convert byte datatype to String datatype.

9. Events btnStop_Click to close server.


CLIENT:
1. Create a System.Net.Sockets.Socket object to connect to the Server.

2. Connect to server with specified address and port with Connect() method.
3. Events btnConnect_Click to connect to Server.

4. Send message to server by Send() method

5. Serialize() create a MemoryStream object to send message to all clients by using


BinaryFormatter object to convert Sting datatype to byte datatype.

6. Events btnSend_Click to execute Send() method.


7. Receive message sent by server.

8. Deserialize() method to convert byte datatype to String datatype.

9. Event Client_FormClosed() to disconect from server.

You might also like