# Connecting, disconnecting from IRC server.

## Functions

int | irc_connect (irc_session_t *session, const char *server, unsigned short port, const char *server_password, const char *nick, const char *username, const char *realname)
| Initiates a connection to IRC server.
int | irc_connect6 (irc_session_t *session, const char *server, unsigned short port, const char *server_password, const char *nick, const char *username, const char *realname)
| Initiates a connection to IRC server using IPv6.
void | irc_disconnect (irc_session_t *session)
| Disconnects a connection to IRC server.
int | irc_is_connected (irc_session_t *session)
| Checks whether the session is connecting/connected to the IRC server.

## Function Documentation

int irc_connect | ( | irc_session_t * | session,
|  | const char * | server,
|  | unsigned short | port,
|  | const char * | server_password,
|  | const char * | nick,
|  | const char * | username,
|  | const char * | realname |
| ) |  |  |

Initiates a connection to IRC server.

Parameters:

  | session | A session to initiate connections on. Must not be NULL.
  | server | A domain name or an IP address of the IRC server to connect to. Must not be NULL.
  | port | An IRC server port, usually 6667.
  | server_password | An IRC server password, if the server requires it. May be NULL, in this case password will not be send to the IRC server. Vast majority of IRC servers do not require passwords.
  | nick | A nick, which libircclient will use to login to the IRC server. Must not be NULL.
  | username | A username of the account, which is used to connect to the IRC server. This is for information only, will be shown in "user properties" dialogs and returned by /whois request. May be NULL, in this case 'nobody' will be sent as username.
  | realname | A real name of the person, who connects to the IRC. Usually people put some wide-available information here (URL, small description or something else). This information also will be shown in "user properties" dialogs and returned by /whois request. May be NULL, in this case 'noname' will be sent as username.

Returns:
  Return code 0 means success. Other value means error, the error code may be obtained through irc_errno(). Any error, generated by the IRC server, is available through irc_callbacks_t::event_numeric.

This function prepares and initiates a connection to the IRC server. The connection is done asynchronously (see irc_callbacks_t::event_connect), so the success return value means that connection was initiated (but not completed!) successfully.

See also:
  irc_run

int irc_connect6 | ( | irc_session_t * | session,
|  | const char * | server,
|  | unsigned short | port,
|  | const char * | server_password,
|  | const char * | nick,
|  | const char * | username,
|  | const char * | realname |
| ) |  |  |

Initiates a connection to IRC server using IPv6.

Parameters:

  | session | A session to initiate connections on. Must not be NULL.
  | server | A domain name or an IP address of the IRC server to connect to. Must not be NULL.
  | port | An IRC server port, usually 6667.
  | server_password | An IRC server password, if the server requires it. May be NULL, in this case password will not be send to the IRC server. Vast majority of IRC servers do not require passwords.
  | nick | A nick, which libircclient will use to login to the IRC server. Must not be NULL.
  | username | A username of the account, which is used to connect to the IRC server. This is for information only, will be shown in "user properties" dialogs and returned by /whois request. May be NULL, in this case 'nobody' will be sent as username.
  | realname | A real name of the person, who connects to the IRC. Usually people put some wide-available information here (URL, small description or something else). This information also will be shown in "user properties" dialogs and returned by /whois request. May be NULL, in this case 'noname' will be sent as username.

Returns:
  Return code 0 means success. Other value means error, the error code may be obtained through irc_errno(). Any error, generated by the IRC server, is available through irc_callbacks_t::event_numeric.

This function prepares and initiates a connection to the IRC server. The connection is done asynchronously (see irc_callbacks_t::event_connect), so the success return value means that connection was initiated (but not completed!) successfully.

See also:
  irc_run

void irc_disconnect | ( | irc_session_t * | session | ) |

Disconnects a connection to IRC server.

Parameters:

  | session | An IRC session.

Returns:
  Return code 0 means success. Other value means error, the error code may be obtained through irc_errno().

This function closes the IRC connection. After that connection is closed, libircclient automatically leaves irc_run loop.

See also:
  irc_connect irc_run

int irc_is_connected | ( | irc_session_t * | session | ) |

Checks whether the session is connecting/connected to the IRC server.

Parameters:

  | session | An initialized IRC session.

Returns:
  Return code 1 means that session is connecting or connected to the IRC server, zero value means that the session has been disconnected.

See also:
  irc_connect irc_run