Tampilkan postingan dengan label Network computing. Tampilkan semua postingan
Tampilkan postingan dengan label Network computing. Tampilkan semua postingan
Creating a Simple Chat Program 2 Direction UDP With C #
Continuing from my previous post about making the program simple chat with TCP , this time I'll share a little about making the program simple chat with the UDP protocol, because if only the TCP incomplete without UDP, happened yesterday is a friend who asked ... heheheh ..
Previously we warm up for a moment to find a glimpse of the UDP protocol. Similar to TCP, UDP is the rule in communication between networks but methods and different properties. These protocols are unreliable, unlike TCP, why? Because the messages are sent as UDP datagrams without a serial number or Ack messages. This protocol is also conectionless, why? Because UDP messages will be sent without having made the connection negotiation process between the two hosts who want berukar information. Then if so to what this protocol is ... .. Usually, UDP is used for network communication that emphasizes speed, and not think about the ability of whether this message until directed safely or not that important messages delivered quickly, and thinking about memory consumption and minimal resources. Examples of technology that uses the RIP (Routing information protocol) on Cisco routers, in addition to the NFS (Network File System) and TFTP (Trivial File Transfer Protocol) also uses UDP you know ... ..
Straight to cut the program just a little explanation.
IPEndPoint ipep = new IPEndPoint (IPAddress.Parse ("127.0.0.1"), 9050);
Socket server = new Socket (AddressFamily.InterNetwork,
SocketType.Dgram, ProtocolType.Udp); server.Connect (ipep);
Similar to TCP, which determines the main we use here only Dgram Socket, socket used in the UDP protocol. For the source code fullnya version i;m share in here. Read More ..
Minggu, April 10, 2011 | 0 Comments
Creating a Simple Chat Program 2 Direction TCP With C #
TCP is a protocol / rules of communication in a communication in computer networks. And the protocol type is the most widely used in building computer networks. What reason was?, Because this is the protocol that provides reliable facilities and security in data transmission. This protocol is often also called connection oriented, why?, Yes because it was an "oriented". The point?, Yes ... .. hehe confused Connection oriented means that in performing the data transmission (communication), before data can be transmitted between two hosts, two processes running on the application layer should negotiate to create session first. And in TCP is often referred to as the "Three-way handshake" or the cool term congratulation greetings ... .. hehe .... About the "Three-way handshake", before sending the data first host (who want to make a connection) will send a TCP segment with SYN flag (one of the TCP flags that indicate the corresponding TCP segment contains the Initial Sequence Number) is switched to the second host ( who would be invited to communicate). Then the second host will respond by sending a segment with ACK (TCP flags that indicate octet field contains the following acknowledgment to be expected in connection) and also to host the first SYN. After that, the first new host will begin exchanging data with the second host. If in everyday terms this process is like the word we want to visit the homes of people, then we should say hello, after greeting us was greeted then the landlord will let us in, only then we can chat with each other.
Okay just a brief explanation of TCP, go straight to the target, about making the program simple two-way chat with C #. Here's a little explanation discount program for client.
IPEndPoint ipep = new IPEndPoint (IPAddress.Parse("127.0.0.1"), 9050);
Socket server = new Socket (AddressFamily.InterNetwork,
SocketType.Stream, ProtocolType.Tcp);
Here the client makes IPEnd point, we first create a new variable called IPEnd point. The ditujuadalah servers, because we practiced in a computer then we just fill in the localhost address 127.0.0.1, if the two computers then input the address of the server computer. After going to make a socket or track, because it is the TCP socket used is Stream.
Then for the class server is a program like the following snippet.
IPEndPoint ipep = new IPEndPoint (IPAddress.Any, 9050);
Newsock socket = new Socket (AddressFamily.InterNetwork,
SocketType.Stream, ProtocolType.Tcp);
The server determines its IPEnd point is that all clients in a single incoming network address. recv = client.Receive (data);
Console.WriteLine (Encoding.ASCII.GetString (data, 0, recv));
Indicates the server program is ready to accept incoming connections.
For full source code i'm share in here. Read More ..
Minggu, April 10, 2011 | 0 Comments
Langganan:
Postingan (Atom)