SlideShare una empresa de Scribd logo
1 de 23
LES SOCKETS
PLAN :
INTRODUCTION
C ’EST QUOI LES SOCKET
SOCKET

 • Les sockets consistent une interface permettant aux applications de
   communiquer soit à travers des réseaux soit en locale .

application                                                     application

                                  socket


 • Le terme socket désigne aussi un canal de communication par la quel
   un processus peut envoyer ou recevoir des données .
MODE CONNECTÉ
MODE NON CONNECTÉ
TYPE DE SOCKET
SOCK_STREAM :
    La communication est en Mode connecter


SOCK_DGRAM :
    La communication est en non connecter


SOCK_RAW :
    Il permet l ’accés a des protocole de bas niveau
DOMAINE DE COMMUNICATION


UNIX INTERNET DECNET ……..




Le domaine INTERNERT spécifier par AF_INET
PROTOCOLE



SOCK_STREAM      TCP


       SOCK_DGRAM        UDP


              SOCK_RAW         ICMP
ALGORITHME D’UN SERVEUR EN MODE CONNECTÉ




  Serveur                      Client
ALGORITHME D’UN CLIENT EN MODE NON
            CONNECTÉ




                           Client
  Serveur
PRIMITIVES
LA CRÉATION D’UNE SOCKET



  int socket(int domain, int type, int protocol);




Exemple : s=socket(PF_INET,SOCK_DGRAM,0);
RENSEIGNEMENT DE LA SOCKET AVEC LES
         INFORMATIONS LOCALES

int bind(int s, struct sockaddr_in * addsock, int lg_addsock);




         Exemple : if (bind(s, &add_sock,sizeof(add_sock)))
       {fprintf(stderr,‘‘Echec dans la réalisation du bind(...)’’);
                      exit(EXIT_BINDING_SOCK);
                                   }
RENSEIGNEMENT DE LA SOCKET POUR LE
          DESTINATAIRE
lg_dint connect(int s, struct sockaddr_in * dest, int est);




  Exemple : if (connect(sock, &addsock, sizeof(addsock)) < 0)
              {perror("Echec de lien de socket");
              exit(EXIT_ERR_CONNECT_SOCK);
                               }
METTRE LE SERVEUR A L ’ ÉTAT D’ÉCOUTE

            int listen(int s, int backlog);




       Exemple : if (listen(sock,MAXCONREQ) < 0)
               {perror("Echec du listen");
                exit(EXIT_ERR_LISTEN);
                            }
DÉFINITION DE L’ENSEMBLE DES CONNEXIONS
               ACCEPTABLES
 int accept(int s, struct sockaddr_in * from, Int * fromlen);




   Exemple : new_sock = accept(s, &add_initiator, &size_add_initiator);
                            if (new_sock < 0)
                      {perror("Echec de l'accept");
                        exit(EXIT_ERR_ACCEPT);
                                    }
TRANSMISSION ET RECEPTION DES DONNEES
          EN MODE CONNECTE



       int write(int s, char * buf, int nbyte);



       int read(int s, char * buf, int nbyte);
TRANSMISSION ET RECEPTION DES DONNEES
        EN MODE NON CONNECTE


  int sendto(int s, char * buf, int nbyte, int flag,struct
           sockaddr_in * dest, int * destlen);




    Int recvfrom(int s, char * buf, int nbyte, int flag,
                            struct sockaddr_in * dest, int *
                          destlen);
FERMETURE D’UNE SOCKET


    Int close(int sock);
Merci de votre
 attention 
CETTE ATELIER EST:

    RÉALISÉ PAR:                 ENCADRÉ PAR:
• ELOUALIDI Soufiane
• ELKASMI Hicham
• BASSKAR Loubna                 Mme F.BENABBOU
• OUYAAZ Hasnaa
• SLIMANI Zakia
• MOUKHLISS Loubna
• DOUMIRI Jihad
• BOUNIT Widad

Más contenido relacionado

La actualidad más candente

Initiation au code : Ateliers en C# (applications desktop et mobile native)
Initiation au code : Ateliers en C# (applications desktop et mobile native)Initiation au code : Ateliers en C# (applications desktop et mobile native)
Initiation au code : Ateliers en C# (applications desktop et mobile native)Stéphanie Hertrich
 
Es15 g formation-ibm-z-os-facilities
Es15 g formation-ibm-z-os-facilitiesEs15 g formation-ibm-z-os-facilities
Es15 g formation-ibm-z-os-facilitiesCERTyou Formation
 
Un compilateur... comment ça marche?
Un compilateur... comment ça marche?Un compilateur... comment ça marche?
Un compilateur... comment ça marche?Dinesh Bolkensteyn
 
initiation SSH_SecuriNets ISI Tunisie
initiation SSH_SecuriNets ISI Tunisieinitiation SSH_SecuriNets ISI Tunisie
initiation SSH_SecuriNets ISI TunisieDonia Hammami
 
Rapport sécurité
Rapport sécuritéRapport sécurité
Rapport sécuritédihiaselma
 
Sécurité et Quaité de code PHP
Sécurité et Quaité de code PHPSécurité et Quaité de code PHP
Sécurité et Quaité de code PHPJean-Marie Renouard
 
Formation C# - Cours 2 - Programmation procédurale
Formation C# - Cours 2 - Programmation procéduraleFormation C# - Cours 2 - Programmation procédurale
Formation C# - Cours 2 - Programmation procéduralekemenaran
 

La actualidad más candente (10)

Initiation au code : Ateliers en C# (applications desktop et mobile native)
Initiation au code : Ateliers en C# (applications desktop et mobile native)Initiation au code : Ateliers en C# (applications desktop et mobile native)
Initiation au code : Ateliers en C# (applications desktop et mobile native)
 
Es15 g formation-ibm-z-os-facilities
Es15 g formation-ibm-z-os-facilitiesEs15 g formation-ibm-z-os-facilities
Es15 g formation-ibm-z-os-facilities
 
Un compilateur... comment ça marche?
Un compilateur... comment ça marche?Un compilateur... comment ça marche?
Un compilateur... comment ça marche?
 
initiation SSH_SecuriNets ISI Tunisie
initiation SSH_SecuriNets ISI Tunisieinitiation SSH_SecuriNets ISI Tunisie
initiation SSH_SecuriNets ISI Tunisie
 
Rapport sécurité
Rapport sécuritéRapport sécurité
Rapport sécurité
 
WeOS Dual Homing
WeOS  Dual HomingWeOS  Dual Homing
WeOS Dual Homing
 
Sécurité et Quaité de code PHP
Sécurité et Quaité de code PHPSécurité et Quaité de code PHP
Sécurité et Quaité de code PHP
 
Formation C# - Cours 2 - Programmation procédurale
Formation C# - Cours 2 - Programmation procéduraleFormation C# - Cours 2 - Programmation procédurale
Formation C# - Cours 2 - Programmation procédurale
 
Client base de données en PHP5
Client base de données en PHP5Client base de données en PHP5
Client base de données en PHP5
 
Présentation de PHP
Présentation de PHPPrésentation de PHP
Présentation de PHP
 

Destacado

Amics per sempre(2014 15)
Amics per sempre(2014 15)Amics per sempre(2014 15)
Amics per sempre(2014 15)carmeo
 
Escalem l´everest
Escalem l´everestEscalem l´everest
Escalem l´everestcarmeo
 
Refractometria joan l_ramos
Refractometria joan l_ramosRefractometria joan l_ramos
Refractometria joan l_ramosaula20_2012
 
Startup funding options for Student Entrepreneurs
Startup funding options for Student EntrepreneursStartup funding options for Student Entrepreneurs
Startup funding options for Student EntrepreneursJohn Spindler
 
Computer components =d
Computer components =dComputer components =d
Computer components =dAmanHeer10
 
Discover south africawww. Tripmart.com
Discover south africawww. Tripmart.comDiscover south africawww. Tripmart.com
Discover south africawww. Tripmart.comtripmart
 
Is 201 group presentation 3
Is 201 group presentation 3Is 201 group presentation 3
Is 201 group presentation 3skroh
 
5M Peyton Civilization
5M Peyton Civilization5M Peyton Civilization
5M Peyton CivilizationgsbSS
 
Top 10 steps to live your best life
Top 10 steps to live your best lifeTop 10 steps to live your best life
Top 10 steps to live your best lifePankaj Raman
 
программирование
программированиепрограммирование
программированиеalex2012_1981
 

Destacado (20)

Excite
ExciteExcite
Excite
 
Dividers fbf
Dividers fbfDividers fbf
Dividers fbf
 
Amics per sempre(2014 15)
Amics per sempre(2014 15)Amics per sempre(2014 15)
Amics per sempre(2014 15)
 
Escalem l´everest
Escalem l´everestEscalem l´everest
Escalem l´everest
 
Refractometria joan l_ramos
Refractometria joan l_ramosRefractometria joan l_ramos
Refractometria joan l_ramos
 
Startup funding options for Student Entrepreneurs
Startup funding options for Student EntrepreneursStartup funding options for Student Entrepreneurs
Startup funding options for Student Entrepreneurs
 
Operating system
Operating systemOperating system
Operating system
 
Computer components =d
Computer components =dComputer components =d
Computer components =d
 
Newspaper analysis 1
Newspaper analysis 1Newspaper analysis 1
Newspaper analysis 1
 
Discover south africawww. Tripmart.com
Discover south africawww. Tripmart.comDiscover south africawww. Tripmart.com
Discover south africawww. Tripmart.com
 
Raid technologies
Raid technologiesRaid technologies
Raid technologies
 
Is 201 group presentation 3
Is 201 group presentation 3Is 201 group presentation 3
Is 201 group presentation 3
 
Dare Ireland presentation
Dare Ireland presentationDare Ireland presentation
Dare Ireland presentation
 
5M Peyton Civilization
5M Peyton Civilization5M Peyton Civilization
5M Peyton Civilization
 
Top 10 steps to live your best life
Top 10 steps to live your best lifeTop 10 steps to live your best life
Top 10 steps to live your best life
 
Lantz inauteri
Lantz inauteriLantz inauteri
Lantz inauteri
 
программирование
программированиепрограммирование
программирование
 
Cast Iron for Eloqua
Cast Iron for EloquaCast Iron for Eloqua
Cast Iron for Eloqua
 
supernatural
supernaturalsupernatural
supernatural
 
3 1 audios
3 1 audios3 1 audios
3 1 audios
 

Similar a Atelier 10

Similar a Atelier 10 (20)

Sockets
SocketsSockets
Sockets
 
Développement informatique : Programmation réseau
Développement informatique : Programmation réseauDéveloppement informatique : Programmation réseau
Développement informatique : Programmation réseau
 
02 java-socket
02 java-socket02 java-socket
02 java-socket
 
module_I6_Sockets.pdf
module_I6_Sockets.pdfmodule_I6_Sockets.pdf
module_I6_Sockets.pdf
 
Socket tcp ip client server on langace c
Socket tcp ip client server on langace c Socket tcp ip client server on langace c
Socket tcp ip client server on langace c
 
Correction TP Horoscope.pdf
Correction TP Horoscope.pdfCorrection TP Horoscope.pdf
Correction TP Horoscope.pdf
 
Les sockets.pptx
Les sockets.pptxLes sockets.pptx
Les sockets.pptx
 
Chapitre-4-Programmation-réseau-avec-les-sockets.pdf
Chapitre-4-Programmation-réseau-avec-les-sockets.pdfChapitre-4-Programmation-réseau-avec-les-sockets.pdf
Chapitre-4-Programmation-réseau-avec-les-sockets.pdf
 
6- Javacousesforenginerss_reseaux_v2.pdf
6- Javacousesforenginerss_reseaux_v2.pdf6- Javacousesforenginerss_reseaux_v2.pdf
6- Javacousesforenginerss_reseaux_v2.pdf
 
SdE 11 - Reseau
SdE 11 - ReseauSdE 11 - Reseau
SdE 11 - Reseau
 
Le Réseau et Java
Le Réseau et JavaLe Réseau et Java
Le Réseau et Java
 
SDE 10 - Reseau
SDE 10 - ReseauSDE 10 - Reseau
SDE 10 - Reseau
 
8-socket.pdf
8-socket.pdf8-socket.pdf
8-socket.pdf
 
Reseau
ReseauReseau
Reseau
 
programmation réseau en java
programmation réseau en java programmation réseau en java
programmation réseau en java
 
Les socket ing1_issat
Les socket ing1_issatLes socket ing1_issat
Les socket ing1_issat
 
Tp1 cours-sockets
Tp1 cours-socketsTp1 cours-sockets
Tp1 cours-sockets
 
Chapitre 3 Comprendre la notion de socket.docx
Chapitre 3 Comprendre la notion de socket.docxChapitre 3 Comprendre la notion de socket.docx
Chapitre 3 Comprendre la notion de socket.docx
 
Rapport Sockets en Java
Rapport Sockets en JavaRapport Sockets en Java
Rapport Sockets en Java
 
Chap7_JavaNet.pdf
Chap7_JavaNet.pdfChap7_JavaNet.pdf
Chap7_JavaNet.pdf
 

Más de Mohamed Amine TALHAOUI (8)

01 absinthe
01 absinthe01 absinthe
01 absinthe
 
Atelier 7
Atelier 7Atelier 7
Atelier 7
 
Atelier6
Atelier6Atelier6
Atelier6
 
Atelier 5
Atelier 5Atelier 5
Atelier 5
 
Atelier 4
Atelier 4Atelier 4
Atelier 4
 
Atelier 3
Atelier 3Atelier 3
Atelier 3
 
Atelier 2
Atelier 2Atelier 2
Atelier 2
 
Atelier 1
Atelier 1Atelier 1
Atelier 1
 

Atelier 10

  • 4. C ’EST QUOI LES SOCKET
  • 5. SOCKET • Les sockets consistent une interface permettant aux applications de communiquer soit à travers des réseaux soit en locale . application application socket • Le terme socket désigne aussi un canal de communication par la quel un processus peut envoyer ou recevoir des données .
  • 8. TYPE DE SOCKET SOCK_STREAM : La communication est en Mode connecter SOCK_DGRAM : La communication est en non connecter SOCK_RAW : Il permet l ’accés a des protocole de bas niveau
  • 9. DOMAINE DE COMMUNICATION UNIX INTERNET DECNET …….. Le domaine INTERNERT spécifier par AF_INET
  • 10. PROTOCOLE SOCK_STREAM TCP SOCK_DGRAM UDP SOCK_RAW ICMP
  • 11. ALGORITHME D’UN SERVEUR EN MODE CONNECTÉ Serveur Client
  • 12. ALGORITHME D’UN CLIENT EN MODE NON CONNECTÉ Client Serveur
  • 14. LA CRÉATION D’UNE SOCKET int socket(int domain, int type, int protocol); Exemple : s=socket(PF_INET,SOCK_DGRAM,0);
  • 15. RENSEIGNEMENT DE LA SOCKET AVEC LES INFORMATIONS LOCALES int bind(int s, struct sockaddr_in * addsock, int lg_addsock); Exemple : if (bind(s, &add_sock,sizeof(add_sock))) {fprintf(stderr,‘‘Echec dans la réalisation du bind(...)’’); exit(EXIT_BINDING_SOCK); }
  • 16. RENSEIGNEMENT DE LA SOCKET POUR LE DESTINATAIRE lg_dint connect(int s, struct sockaddr_in * dest, int est); Exemple : if (connect(sock, &addsock, sizeof(addsock)) < 0) {perror("Echec de lien de socket"); exit(EXIT_ERR_CONNECT_SOCK); }
  • 17. METTRE LE SERVEUR A L ’ ÉTAT D’ÉCOUTE int listen(int s, int backlog); Exemple : if (listen(sock,MAXCONREQ) < 0) {perror("Echec du listen"); exit(EXIT_ERR_LISTEN); }
  • 18. DÉFINITION DE L’ENSEMBLE DES CONNEXIONS ACCEPTABLES int accept(int s, struct sockaddr_in * from, Int * fromlen); Exemple : new_sock = accept(s, &add_initiator, &size_add_initiator); if (new_sock < 0) {perror("Echec de l'accept"); exit(EXIT_ERR_ACCEPT); }
  • 19. TRANSMISSION ET RECEPTION DES DONNEES EN MODE CONNECTE int write(int s, char * buf, int nbyte); int read(int s, char * buf, int nbyte);
  • 20. TRANSMISSION ET RECEPTION DES DONNEES EN MODE NON CONNECTE int sendto(int s, char * buf, int nbyte, int flag,struct sockaddr_in * dest, int * destlen); Int recvfrom(int s, char * buf, int nbyte, int flag, struct sockaddr_in * dest, int * destlen);
  • 21. FERMETURE D’UNE SOCKET Int close(int sock);
  • 22. Merci de votre attention 
  • 23. CETTE ATELIER EST: RÉALISÉ PAR: ENCADRÉ PAR: • ELOUALIDI Soufiane • ELKASMI Hicham • BASSKAR Loubna Mme F.BENABBOU • OUYAAZ Hasnaa • SLIMANI Zakia • MOUKHLISS Loubna • DOUMIRI Jihad • BOUNIT Widad