Create Socket:
Create a socket that can be used to communicate on a TCP / IP network (such as the Internet). Socket S = New Socket (AddressFamily.internetwork, sockettype.stream, protocoltype.tcp); To use UDP instead of TCP. Socket S = New Socket (AddressFamily.Internetwork, sockettype.dgram, protocoltype.ud);
Related class:
TCP / IP uses a network address and a service port number to uniquely identify the device. Network address identifies a specific device; port number identifies specific services on the device. The combination is called endpoint, which is represented by the endpoint class in the .NET Framework. Define the sub-generation of EndPoint for each supported address family; for the IP address family, this class is IpendPoint. The DNS class provides domain name services to applications that use TCP / IP Internet services. The Resolve method queries the DNS server to map the user-friendly domain name (such as "host.contoso.com" to the digital form of Internet address (eg 192.168.1.1). Resolve returns an iPhostenty that contains the list of addresses and aliases of the requested name. In most cases, you can use the first address returned in the AddressList array. The following code gets an ipaddress that contains the IP address of the server host.contoso.com. IPHOSTENTRY iphostinfo = dns.resolve ("host.contoso.com"); ipaddress ipaddress = iphostinfo.addresslist [0];
IpendPoint Ipe = New IpendPoint (ipaddress, 11000);
Socket method:
Receive data: Receive or BeginReceive / endReceive
Send data: send or beginsend / endsend
Listening: use
Bind
Method
Socket
Associate with this endpoint, use
Listen
method
ListenerSocket.bind (localendpoint); listenerSocket.Listen (100); // 100 represents up to 100 clients can be placed in the connection queue
Use the Accept method to get a connection (socket). Also have BeginAccept and Endaccept.