1
0
Fork 0
mirror of https://git.rwth-aachen.de/acs/public/villas/node/ synced 2025-03-09 00:00:00 +01:00

more cleanup

git-svn-id: https://zerberus.eonerc.rwth-aachen.de:8443/svn/s2ss/trunk@43 8ec27952-4edc-4aab-86aa-e87bb2611832
This commit is contained in:
Steffen Vogel 2014-06-05 09:35:16 +00:00
parent facadafb2e
commit 36e6b20ad5
3 changed files with 12 additions and 19 deletions

View file

@ -40,7 +40,7 @@ int node_connect(struct node *n)
/* Create socket */
n->sd = socket(AF_INET, SOCK_DGRAM, 0);
if (n->sd < 0)
error("Failed to create socket: %s", strerror(errno));
perror("Failed to create socket");
/* Set socket options */
int prio = SOCKET_PRIO;
@ -49,14 +49,9 @@ int node_connect(struct node *n)
/* Bind socket for receiving */
if (bind(n->sd, (struct sockaddr *) &n->local, sizeof(struct sockaddr_in)))
error("Failed to bind socket: %s", strerror(errno));
perror("Failed to bind to socket");
debug(1, " We listen for node %s at %s:%u", n->name, inet_ntoa(n->local.sin_addr), ntohs(n->local.sin_port));
/* Connect socket for sending */
/*if (connect(n->sd, (struct sockaddr *) &n->remote, sizeof(struct sockaddr_in)))
error("Failed to connect socket: %s", strerror(errno));*/
debug(1, " We sent to node %s at %s:%u", n->name, inet_ntoa(n->remote.sin_addr), ntohs(n->remote.sin_port));
return 0;

View file

@ -13,8 +13,6 @@
#include "utils.h"
#include "path.h"
extern struct config config;
int path_create(struct path *p, struct node *in, struct node *out)
{
/* Reset counters */

View file

@ -33,14 +33,16 @@ int main(int argc, char *argv[])
struct sockaddr_in sa;
if (argc != 2) {
printf("Usage: %s REMOTE\n", argv[0]);
printf(" REMOTE is a IP:PORT combination of the remote host\n\n");
printf("Usage: %s REMOTE VALUES\n", argv[0]);
printf(" REMOTE is a IP:PORT combination of the remote host\n");
printf(" VALUES is the number of values to be read from stdin\n\n");
printf("s2ss Simulator2Simulator Server v%s\n", VERSION);
printf("Copyright 2014, Institute for Automation of Complex Power Systems, EONERC\n");
exit(EXIT_FAILURE);
}
const char *remote_str = argv[1];
int values = atoi(argv[2]);
/* Setup signals */
struct sigaction sa_quit = {
@ -63,19 +65,17 @@ int main(int argc, char *argv[])
if (sd < 0)
perror("Failed to create socket");
// TODO: remove workaround
struct msg msg = {
.length = 5 * sizeof(double)
};
/* Connect socket */
if (connect(sd, (struct sockaddr *) &remote, sizeof(struct sockaddr_in)))
perror("Failed to connect socket");
struct msg m;
m.length = values * sizeof(double);
while (!feof(stdin)) {
msg_fscan(stdin, &msg);
send(sd, &msg, 8 + msg.length, 0);
msg_fprint(stdout, &msg);
msg_fscan(stdin, &m);
send(sd, &m, 8 + m.length, 0);
msg_fprint(stdout, &m);
}
return 0;