Commit fdfd3146 authored by Sven Gestegård Robertz's avatar Sven Gestegård Robertz
Browse files

actually added

parent f43dd755
......@@ -20,7 +20,8 @@ struct labcomm_encoder *enc_init( int fd) {
return encoder;
}
void enc_run(struct labcomm_encoder * encoder) {
void enc_run(struct labcomm_encoder *encoder, jg_foo *v) {
#if 0
jg_foo v;
v.b = 17.17;
......@@ -31,12 +32,12 @@ void enc_run(struct labcomm_encoder * encoder) {
v.g = 42;
v.h = 2;
v.i = 42.42;
#endif
labcomm_encode_jg_foo(encoder, &v);
usleep(500000);
v.f += 42;
v.h += 42017040;
labcomm_encode_jg_foo(encoder, &v);
v->b += 42;
v->h += 42000000;
labcomm_encode_jg_foo(encoder, v);
}
void enc_cleanup(struct labcomm_encoder *encoder) {
......
......@@ -3,6 +3,8 @@
#include <labcomm_default_memory.h>
#include <labcomm_default_scheduler.h>
#include "jg.h"
struct labcomm_encoder *enc_init(int fd) ;
void enc_run(struct labcomm_encoder *encoder) ;
void enc_run(struct labcomm_encoder *encoder, jg_foo *v) ;
void enc_cleanup(struct labcomm_encoder *encoder) ;
......@@ -7,6 +7,7 @@
#include <netinet/in.h>
#include <netdb.h>
#include "jg.h"
#include "dec.h"
#include "enc.h"
......@@ -16,10 +17,13 @@ void error(const char *msg)
exit(0);
}
void do_labcomm(int sockfd)
void do_labcomm(int sockfd, jg_foo *v)
{
void *enc = enc_init(sockfd);
enc_run(enc);
int i;
for(i=0; i<10;i++) {
enc_run(enc, v);
}
enc_cleanup(enc);
}
......@@ -40,6 +44,11 @@ int main(int argc, char *argv[])
if (sockfd < 0)
error("ERROR opening socket");
int so_reuseaddr = 1; //TRUE;
if(setsockopt(sockfd,SOL_SOCKET,SO_REUSEADDR, &so_reuseaddr, sizeof so_reuseaddr)) {
error("ERROR setting socket options");
}
bzero((char *) &serv_addr, sizeof(serv_addr));
serv_addr.sin_addr.s_addr = INADDR_ANY;
......@@ -59,8 +68,19 @@ int main(int argc, char *argv[])
perror("ERROR on accept");
exit(1);
}
jg_foo v;
v.b = 17.17;
v.c = 1742;
v.d = 4217;
v.e = "hello";
v.f = 17;
v.g = 42;
v.h = 2;
v.i = 42.42;
do_labcomm(newsockfd);
do_labcomm(newsockfd, &v);
close(newsockfd);
close(sockfd);
......
Supports Markdown
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