ElHuaco / IRC-server

The goal of this project is to make you write your own IRC server. To do so, you will follow the real IRC RFC and test your work with real IRC clients. Internet is ruled by solid and standards protocols that allow a strong interaction between every connected computer. It’s always good to know about it.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool


ft_irc

ℹ️ About The Project

42 Project

The goal of this project is to make you write your own IRC server. To do so, you will follow the real IRC RFC and test your work with real IRC clients. Internet is ruled by solid and standards protocols that allow a strong interaction between every connected computer. It’s always good to know about it.

Subject

Steps

  1. Beej's Guide to Network Programming
  2. Beej's cheesy chat example
  3. RFC for Human beings
  4. ????
  5. Profit

RFC Documentation

Request For Comments, official documentation for IRC.

Allowed functions

Expand
  • socket(): lo crea. Selecciona protocolos (PF_INET ó PF_INET6; SOCK_STREAM; getprotobyname("tcp")). También se puede rellenar con el struct addrinfo usado en getaddrinfo().
  • setsockopt(), getsockname(): controlar socket descriptors, como fcntl().
  • getprotobyname(): devuelve el número asociado al nombre del protocolo, como "tcp" o "udp".
  • gethostbyname(): da la dirección IP de un host name. No funciona bien con IPv6. Mejor usar getaddrinfo().
  • getaddrinfo(), freeaddrinfo(): recibe información de un host name y un struct addrinfo con los tipos de IP y sockets a usar. Rellena el struct sockaddr con el resultado y crea una lista de struct addrinfo con las direcciones que cumplen la información pasada de argumento. Esta lista se libera con freeaddrinfo().
  • bind(): asocia un socket con una IP y puerto.
  • connect(): conecta un socket a un servidor. Tras bind() si se queria el cliente en una IP y puerto concretos. Permite llamar a send() y recv().
  • listen(): que el socket descriptor escuche conexiones entrantes. Especifica número máximo de conexiones.
  • accept(): acepta una conexión entrante en un listening socket. Tras haber creado un SOCK_STREAMy haberlo preparado para conexiones entrantes con listen(), llamas a esta función para crear un nuevo socket descriptor que pueda ser usado para las siguientes comunicaciones con el nuevo cliente. El socket anterior sigue estando ahí y podrá ser usado para nuevos accept(). Hay que close()este nuevo socket cuando terminemos.
  • htons(), htonl(), ntohs(), ntohl(): convierten integer types de host byte order a network byte order y viceversa, según si preparas para enviar el tipo, o lo has recibido.
  • inet_addr(), inet_ntoa(): convierte dirección IP en char a struct in_addr y viceversa. No admiten IPv6.
  • send(): envía datos a través de un TCP socket. Para un chat habrá que determinar cuando empieza y termina un mensaje en el working buffer de recv(), por los posibles envíos parciales de información -> estructura de paquete con (longitud, usuario, mensaje) o similar, según sea RFC, para llamar a recv() hasta que los bytes recibidos sean igual al que pone en longitud. El working buffer debe tener el tamaño de 2 paquetes al menos porque podemos enviar la parte final de uno y el comienzo del siguiente antes de operar con el primero.
  • recv(): lee datos entrantes del remoto al buffer. Devuelve los bytes recibidos. Si el remoto ha cerrado la conexión, devuelve 0.
  • fcntl(socket_fd, F_SETFL, O_NONBLOCK): hace al socket descriptor non-blocking.
  • select(), poll(), kqueue(), epoll(): forma de que un solo thread trabaje con varios socket descriptors. Gives you the power to monitor several sockets at the same time. It’ll tell you which ones are ready for reading, which are ready for writing, and which sockets have raised exceptions.
  • FD_CLR: removes a particular fd from the set.
  • FD_COPY: reemplaza un fd set por otro.
  • FD_ISSET: returns true if fd is in the set.
  • FD_SET: adds fd to the set.
  • FD_ZERO: clears all entries from the set.
  • signal
  • lseek
  • fstat

(back to top)

🏃 Quick Start

Important

  • Project has only been tested and runned on macOS systems

Installation

  • Clone the repo
    git clone https://github.com/its-a-maxi/ft_irc.git

(back to top)

⌨️ Usage

  • Compile
  make
  • Run
  ./ircserv [host:port_network:password_network] <port> <password>

(back to top)

📫 Contact

Maximo Monroy - monroy.vds@gmail.com

Alejandro León - https://github.com/ElHuaco

Fernando Jimenez - https://github.com/fjimenez81

Project Link: https://github.com/its-a-maxi/ft_irc

(back to top)

🥇 Acknowledgments

(back to top)

About

The goal of this project is to make you write your own IRC server. To do so, you will follow the real IRC RFC and test your work with real IRC clients. Internet is ruled by solid and standards protocols that allow a strong interaction between every connected computer. It’s always good to know about it.


Languages

Language:C++ 96.9%Language:Makefile 3.1%