Sokets tutorial

Solo disponible en BuenasTareas
  • Páginas : 23 (5532 palabras )
  • Descarga(s) : 0
  • Publicado : 24 de noviembre de 2011
Leer documento completo
Vista previa del texto
Linux Howtos: C/C++ -> Sockets Tutorial howtos, tips&tricks and tutorials for linux
search for: fulltextsearch search text in: howtos manpages Home News Archive links from external sites Network LDAP Infrared Devices Graphics Gimp creating an analog gauge image OpenGL Programming C/C++ CGI Secure programming Misc VI SystemPCMCIA Security Tips and Tricks Browser plugins Help out Distributions specific Gentoo Fedora contact interesting sites german sites manpages tools FAQ Sitemap You are here: Programming->C/C++ .

Sockets Tutorial
This is a simple tutorial on using sockets for interprocess communication.

The client server model
Most interprocess communication uses the client server model. These terms refer tothe two processes which will be communicating with each other. One of the two processes, the client, connects to the other process, the server, typically to make a request for information. A good analogy is a person who makes a phone call to another person. Notice that the client needs to know of the existence of and the address of the server, but the server does not need to know the address of (oreven the existence of) the client prior to the connection being established. Notice also that once a connection is established, both sides can send and receive information. The system calls for establishing a connection are somewhat different for the client and the server, but both involve the basic construct of a socket. A socket is one end of an interprocess communication channel. The twoprocesses each establish their own socket. The steps involved in establishing a socket on the client side are as follows: 1. Create a socket with the socket() system call 2. Connect the socket to the address of the server using the connect() system call 3. Send and receive data. There are a number of ways to do this, but the simplest is to use the read() and write() system calls. The steps involved inestablishing a socket on the server side are as follows: 1. Create a socket with the socket() system call 2. Bind the socket to an address using the bind() system call. For a server socket on the Internet, an address consists of a port number on the host machine. 3. Listen for connections with the listen() system call 4. Accept a connection with the accept() system call. This call typically blocksuntil a client connects with the server. 5. Send and receive data

other Ads Stellenangebote Stellenangebote für Fach- und Führungskräfte

Other free services Shorten long URLs to short links like


Poll Which linux distribution do you use? SuSe FedoraMandrake Gentoo RedHat Debian other vote poll results Last additions:

FeedCollector Combine various newsfeeds to one customized webpage

Socket Types
When a socket is created, the program has to specify the address domain and the socket type. Two processes can communicate with each other only if their sockets are of the same type and in the same domain. There are twowidely used address domains, the unix domain, in which two processes which share a common file system communicate, and the

Reverse DNS lookup Find out which hostname(s) resolve to a given IP or other hostnames for the server

1 de 13

06/01/11 22:55

Linux Howtos: C/C++ -> Sockets Tutorial
using iotop to find disk usage hogs May 25th. 2007: why adblockers are bad

Internet domain, in which two processes running on any two hosts on the Internet communicate. Each of these has its own address format. The address of a socket in the Unix domain is a character string which is basically an entry in the file system. The address of a socket in the Internet domain consists of the Internet address of the host...
tracking img