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

File containing the IRC_Connection struct and related functions. More...

Go to the source code of this file.

Data Structures

struct  IRC_Connection
 IRC_Connection struct holds the socket handle, receiving buffer and basic info about the connection. More...
 

Macros

#define INVALID_SOCKET   ((SOCKET)(~0))
 
#define SOCKET_ERROR   (-1)
 

Typedefs

typedef int SOCKET
 
typedef struct IRC_Connection IRC_Connection
 IRC_Connection struct holds the socket handle, receiving buffer and basic info about the connection. More...
 

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_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...
 
int connection_disconnect (IRC_Connection *connection)
 Disconnect from remote server and close the socket. More...
 

Detailed Description

File containing the IRC_Connection struct and related functions.

Author
Mateusz Makowski
Date
15.09.2018

Typedef Documentation

◆ IRC_Connection

IRC_Connection struct holds the socket handle, receiving buffer and basic info about the connection.

See also
connection_create()

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