Skip to content

Commit

Permalink
Don't allow setting the multicast group and port. The client doesn't …
Browse files Browse the repository at this point in the history
…allow listening on different groups and ports and since there are no collisions possible it makes no sense to change it, unless there's something wonky about multicast that I don't know.
  • Loading branch information
BSVino committed Aug 11, 2014
1 parent d3322de commit 8b626ae
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 53 deletions.
12 changes: 2 additions & 10 deletions server/viewback.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,7 @@ void vb_config_initialize(vb_config_t* config)
{
memset(config, 0, sizeof(vb_config_t));

config->multicast_group = VB_DEFAULT_MULTICAST_ADDRESS;
config->tcp_port = VB_DEFAULT_PORT;
config->multicast_port = VB_DEFAULT_PORT;
config->max_connections = 4;
}

Expand Down Expand Up @@ -137,12 +135,6 @@ vb_bool vb_config_install(vb_config_t* config, void* memory, size_t memory_size)

VB->server_active = 0;

if (!VB->config.multicast_group || !*VB->config.multicast_group)
VB->config.multicast_group = VB_DEFAULT_MULTICAST_ADDRESS;

if (!VB->config.multicast_port)
VB->config.multicast_port = VB_DEFAULT_PORT;

if (!VB->config.tcp_port)
VB->config.tcp_port = VB_DEFAULT_PORT;

Expand Down Expand Up @@ -530,8 +522,8 @@ vb_bool vb_server_create()

memset(&VB->multicast_addr, 0, sizeof(VB->multicast_addr));
VB->multicast_addr.sin_family = AF_INET;
VB->multicast_addr.sin_addr.s_addr = inet_addr(VB->config.multicast_group);
VB->multicast_addr.sin_port = htons(VB->config.multicast_port);
VB->multicast_addr.sin_addr.s_addr = inet_addr(VB_DEFAULT_MULTICAST_ADDRESS);
VB->multicast_addr.sin_port = htons(VB_DEFAULT_PORT);
VB->last_multicast = 0;

VB->tcp_socket = socket(AF_INET, SOCK_STREAM, 0);
Expand Down
23 changes: 4 additions & 19 deletions server/viewback.h
Original file line number Diff line number Diff line change
Expand Up @@ -160,27 +160,12 @@ typedef struct {
*/
vb_debug_output_callback debug_output_callback;

/*
Must be a valid IP group eg "239.127.251.37" If this is NULL the
default will be used. See: http://en.wikipedia.org/wiki/Multicast_address
If you change this then Viewback clients won't be able to connect
automatically and will have to connect manually. You should probably
leave it 0 unless your network is special.
*/
const char* multicast_group;

/*
This port will be used for UDP multicast connections. 0 means use the
default port. If you change this then Viewback clients won't be able
to connect automatically and will have to connect manually. You should
probably leave it 0 unless your network is special.
*/
unsigned short multicast_port;

/*
This port will be used for TCP connections. 0 means use an automatically
assigned default port. The multicast signal broadcasts the TCP port so
there's no reason to set this unless your network is special.
assigned default port. If the specified port is not available, the next
5 ports will be tried until an open port is found. The multicast signal
broadcasts the TCP port so there's no reason to set this unless your
network is special.
*/
unsigned short tcp_port;

Expand Down
14 changes: 0 additions & 14 deletions server/viewback_util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,6 @@ class CVBUtilConfig
unsigned char max_connections;
vb_debug_output_callback output;
vb_command_callback command;
const char* multicast_group;
unsigned short multicast_port;
unsigned short tcp_port;
} g_util_config;

Expand Down Expand Up @@ -280,16 +278,6 @@ void vb_util_set_command_callback(vb_command_callback command)
g_util_config.command = command;
}

void vb_util_set_multicast_group(const char* multicast_group)
{
g_util_config.multicast_group = multicast_group;
}

void vb_util_set_multicast_port(unsigned short multicast_port)
{
g_util_config.multicast_port = multicast_port;
}

void vb_util_set_tcp_port(unsigned short tcp_port)
{
g_util_config.tcp_port = tcp_port;
Expand Down Expand Up @@ -337,8 +325,6 @@ vb_bool vb_util_server_create(const char* server_name)
if (g_util_config.max_connections)
config.max_connections = g_util_config.max_connections;

config.multicast_group = g_util_config.multicast_group;
config.multicast_port = g_util_config.multicast_port;
config.tcp_port = g_util_config.tcp_port;
config.debug_output_callback = g_util_config.output;
config.command_callback = g_util_config.command;
Expand Down
2 changes: 0 additions & 2 deletions server/viewback_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,6 @@ void vb_util_add_control_slider_int(const char* name, int range_min, int range_m
void vb_util_set_max_connections(unsigned char max_connections);
void vb_util_set_output_callback(vb_debug_output_callback output);
void vb_util_set_command_callback(vb_command_callback command);
void vb_util_set_multicast_group(const char* multicast_group);
void vb_util_set_multicast_port(unsigned short multicast_port);
void vb_util_set_tcp_port(unsigned short tcp_port);

/*
Expand Down
8 changes: 0 additions & 8 deletions tests/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ int main(int argc, const char** args)
vb_util_initialize();

unsigned short port = 0;
const char* multicast_group = NULL;

for (int i = 1; i < argc; i++)
{
Expand All @@ -120,11 +119,6 @@ int main(int argc, const char** args)
i++;
port = (unsigned short)atoi(args[i]);
}
else if (strcmp(args[i], "--multicast-group") == 0 && i < argc - 1)
{
i++;
multicast_group = args[i];
}
}

vb_channel_handle_t vb_keydown, vb_player, vb_health, vb_mousepos;
Expand Down Expand Up @@ -204,8 +198,6 @@ int main(int argc, const char** args)
vb_util_add_control_slider_int("Bots", 0, 6, 1, &bots_callback);
vb_util_add_control_button("Infinite loop", &freeze_callback);

vb_util_set_multicast_group(multicast_group);
vb_util_set_tcp_port(port);
vb_util_set_output_callback(&debug_printf);
vb_util_set_command_callback(&command_callback);

Expand Down

0 comments on commit 8b626ae

Please sign in to comment.