Skip to content

Internet Relay Chat or IRC is a text-based communication protocol on the Internet. It offers real-time messaging that can be either public or private. Users can exchange direct messages and join group channels.

Notifications You must be signed in to change notification settings

SaidM96/ft_IRC42

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ft_irc-

functions

listen() function is a socket function that is used to listen for incoming connections on a specified socket. It sets the maximum number of connections that can be queued for a specific socket.
exemple:

#include <sys/types.h>
#include <sys/socket.h>

int listen(int socket, int backlog);

The first parameter, socket, is the socket descriptor that you want to listen on.
The second parameter, backlog, is the maximum number of connections that can be queued for the socket.
return value:
0 : was successfully and the socket now is listening for incoming connections
1 : indicated that an error occurred
select() function is a system call that allows a program to monitor multiple file descriptors, waiting until one or more of the file descriptors become "ready" for some class of I/O operation (e.g. input possible). It can be used to monitor multiple sockets or other file descriptors for readability, writability, or errors.
exemple:

#include <sys/select.h>

int select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout);

nfds is the highest-numbered file descriptor in any of the descriptor sets, plus 1 or can use FD_SETSIZE.
FD_SETSIZE is a macro define in the header <sys/select.h> that specifies the maximum number of the file descriptor that can be monitorin by the select()
readfds is a descriptor set containing the file descriptors to be checked for readability
writefds is a descriptor set containing the file descriptors to be checked for writability
exceptfds is a descriptor set containing the file descriptors to be checked for errors
timeout is a pointer to a struct timeval that specifies the maximum time to wait for an event to occur before returning.
FD_SET(sockfd, &readfds) : is use to set the sockfd to the set of readability
FD_ZERO(&readfds) : is use to clear the set of readability
FD_ISSET(sockfd, &readfds) : is use to check if this file descriptor sockfd inside the set of readability or not

About

Internet Relay Chat or IRC is a text-based communication protocol on the Internet. It offers real-time messaging that can be either public or private. Users can exchange direct messages and join group channels.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published