Freeciv-3.1: /fast/freeciv/nightly/S3_1/server/sernet.h File Reference

Freeciv-3.1

Loading...
Searching...
No Matches
Macros | Enumerations | Functions
sernet.h File Reference

Go to the source code of this file.

## Macros

#define | BUF_SIZE 512
#define | SERVER_LAN_PORT 4555
#define | SERVER_LAN_TTL 1
#define | SERVER_LAN_VERSION 2

## Enumerations

enum | server_events { S_E_END_OF_TURN_TIMEOUT , S_E_OTHERWISE , S_E_FORCE_END_OF_SNIFF }

## Functions

enum server_events | server_sniff_all_input (void)
int | server_open_socket (void)
void | flush_packets (void)
void | close_connections_and_socket (void)
void | init_connections (void)
int | server_make_connection (int new_sock, const char *client_addr, const char *client_ip)
void | handle_conn_pong (struct connection *pconn)
void | handle_client_heartbeat (struct connection *pconn)
void | readline_atexit (void)

## Macro Definition Documentation

## ◆ BUF_SIZE

#define BUF_SIZE 512

Definition at line 22 of file sernet.h.

## ◆ SERVER_LAN_PORT

#define SERVER_LAN_PORT 4555

Definition at line 24 of file sernet.h.

## ◆ SERVER_LAN_TTL

#define SERVER_LAN_TTL 1

Definition at line 25 of file sernet.h.

## ◆ SERVER_LAN_VERSION

#define SERVER_LAN_VERSION 2

Definition at line 26 of file sernet.h.

## Enumeration Type Documentation

## ◆ server_events

enum server_events

Enumerator
S_E_END_OF_TURN_TIMEOUT |
S_E_OTHERWISE |
S_E_FORCE_END_OF_SNIFF |

Definition at line 28 of file sernet.h.

## Function Documentation

## ◆ close_connections_and_socket()

void close_connections_and_socket | ( | void |  | ) |

Close all network stuff: connections, listening sockets, metaserver connection...

Definition at line 259 of file sernet.c.

Referenced by server_quit().

## ◆ flush_packets()

void flush_packets | ( | void |  | ) |

Attempt to flush all information in the send buffers for upto 'netwait' seconds.

Definition at line 379 of file sernet.c.

Referenced by begin_phase(), dai_do_first_activities(), end_phase(), send_all_known_cities(), send_all_known_tiles(), and send_all_known_units().

## ◆ handle_client_heartbeat()

void handle_client_heartbeat | ( | struct connection * | pconn | ) |

Handle client's regular hearbeat

Definition at line 1451 of file sernet.c.

## ◆ handle_conn_pong()

void handle_conn_pong | ( | struct connection * | pconn | ) |

Handle response to ping.

Definition at line 1431 of file sernet.c.

## ◆ init_connections()

void init_connections | ( | void |  | ) |

Initialize connection related stuff. Attention: Logging is not available within this functions!

Definition at line 1355 of file sernet.c.

Referenced by main(), and srv_prepare().

## ◆ readline_atexit()

void readline_atexit | ( | void |  | ) |

Clear readline stuff at exit. To cater for as many different cases as possible, we call this both like any function call from server_quit() before exit(), and as a atexit handler. Former is to get everything cleared already before exit(), before any other atexit handler comes to play. Latter is to make sure that the function gets called also when in those rare cases where we exit some other way than server_quit() - that's important for always restoring terminal to a working state.

That means that in usual case this function gets called twice. Make sure that it doesn't try double frees or similar when that happens.

Definition at line 209 of file sernet.c.

Referenced by server_quit(), and server_sniff_all_input().

## ◆ server_make_connection()

int server_make_connection | ( | int | new_sock,
|  | const char * | client_addr,
|  | const char * | client_ip
| ) |  |

Server accepts connection from client: Low level socket stuff, and basic-initialize the connection struct. Returns 0 on success, -1 on failure (bad accept(), or too many connections).

Definition at line 1067 of file sernet.c.

Referenced by server_accept_connection().

## ◆ server_open_socket()

int server_open_socket | ( | void |  | ) |

Open server socket to be used to accept client connections and open a server socket for server LAN announcements.

Definition at line 1127 of file sernet.c.

Referenced by srv_prepare().

## ◆ server_sniff_all_input()

enum server_events server_sniff_all_input | ( | void |  | ) |

Get and handle:

- new connections,
- input from connections,
- input from server operator in stdin

This function also handles prompt printing, via the con_prompt_* functions. That is, other functions should not need to do so. –dwp

Definition at line 524 of file sernet.c.

Referenced by srv_main(), and srv_running().