Commit 79a24049 authored by Felix Brüning's avatar Felix Brüning
Browse files

fixed error in sending from pos

parent 44fe4828
#include "create_socket.h"
int ports[] = {IXL_PORT, TRAIN_BLACK_PORT, TRAIN_RED_PORT, TRAIN_BLUE_PORT, TRAIN_GREEN_PORT};
int ids[] = {IXL_ID, TRAIN_BLACK, TRAIN_RED, TRAIN_BLUE, TRAIN_GREEN };
int ports_sending[] = {IXL_PORT, TRAIN_BLACK_PORT, TRAIN_RED_PORT, TRAIN_BLUE_PORT, TRAIN_GREEN_PORT};
int ids_rec[] = {IXL_ID, TRAIN_BLACK, TRAIN_RED, TRAIN_BLUE, TRAIN_GREEN };
void create_udp_socket(int *socket_fd, int can_broadcast){
if ((*socket_fd = router_socket(AF_INET, SOCK_DGRAM, 0)) < 0 ) {
......@@ -48,7 +48,7 @@ void create_socket(int can_broadcast, int train){
for(int i = 0; i < 5; i++)
{
create_udp_socket(&CONNECTIONS[i].sockfd, can_broadcast);
fill_socket(&CONNECTIONS[i].addr, ports[i], RECV_ADDR);
fill_socket(&CONNECTIONS[i].addr, ports_sending[i], RECV_ADDR);
bind_socket(CONNECTIONS[i].sockfd, &CONNECTIONS[i].addr);
}
#else
......@@ -119,7 +119,7 @@ int send_from_pos(BYTE *buf, int length)
for(int i = 0; i < 5; i++)
{
struct sockaddr_in temp_send;
fill_socket(&temp_send, ports[i], BROADCAST_ADDR);
fill_socket(&temp_send, ports_sending[i], BROADCAST_ADDR);
size_t r = router_sendto(CONNECTIONS[i].sockfd, buf, length, MSG_CONFIRM, (const struct sockaddr *) &temp_send, sizeof(temp_send));
if(r){
plog(DEBUG, "Message sent - to: %s", inet_ntoa(temp_send.sin_addr));
......
......@@ -38,8 +38,8 @@ struct connection MAERKLIN_SOCK;
#ifdef POS
struct connection CONNECTIONS[5];
extern int ports[5];
extern int ids[5];
extern int ports_sending[5];
extern int ids_rec[5];
#else
struct connection MODULE_COMM_SOCK;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment