ircbot.c  0.3.0
Multi-platform IRC bot in pure C
connection.c File Reference

Implementation of connection.h. More...

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <sys/socket.h>
#include <unistd.h>
#include "connection.h"

Macros

#define ERROR   0
 
#define OK   1
 

Functions

IRC_Connectionconnection_create (const char address[], const char port[])
 "Constructor" for IRC_Connection. More...
 
int connection_connect (IRC_Connection *connection)
 Actually connect to the remote server specified in connection_create(). More...
 
int connection_disconnect (IRC_Connection *connection)
 Disconnect from remote server and close the socket. More...
 
int connection_send (IRC_Connection *connection, const char msg[])
 Send data (char) to remote server. More...
 
int connection_read (IRC_Connection *connection)
 Receive data from remote server. More...
 

Detailed Description

Implementation of connection.h.

Author
Mateusz Makowski
Date
17.09.2018

Function Documentation

◆ connection_connect()

int connection_connect ( IRC_Connection connection)

Actually connect to the remote server specified in connection_create().

Parameters
connectiona pointer to IRC_Connection object
Returns
1 on success, 0 on failure

◆ connection_create()

IRC_Connection* connection_create ( const char  address[],
const char  port[] 
)

"Constructor" for IRC_Connection.

The preferred way to create new connections.

Parameters
addressa string with the server's URI
porta string with the port to be used
Returns
pointer to newly created IRC_Connection or null pointer on failure

◆ connection_disconnect()

int connection_disconnect ( IRC_Connection connection)

Disconnect from remote server and close the socket.

Parameters
connectiona pointer to IRC_Connection object
Returns
1 on success, 0 on failure

◆ connection_read()

int connection_read ( IRC_Connection connection)

Receive data from remote server.

Parameters
connectiona pointer to IRC_Connection object
Returns
1 on success, 0 on failure

◆ connection_send()

int connection_send ( IRC_Connection connection,
const char  msg[] 
)

Send data (char) to remote server.

Parameters
connectiona pointer to IRC_Connection object
msgdata to be sent
Returns
1 on success, 0 on failure