Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
T
tsn-measures
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
tsn-measures
Commits
2c4701fa
Commit
2c4701fa
authored
Apr 08, 2020
by
Joanne Hugé
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make the server ip a parameter
parent
64b3fb41
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
22 additions
and
16 deletions
+22
-16
simple-client/build/Makefile
simple-client/build/Makefile
+11
-1
simple-client/build/main_arm
simple-client/build/main_arm
+0
-0
simple-client/src/main.c
simple-client/src/main.c
+7
-2
simple-client/src/send_packet.c
simple-client/src/send_packet.c
+3
-12
simple-client/src/send_packet.h
simple-client/src/send_packet.h
+1
-1
No files found.
simple-client/build/Makefile
View file @
2c4701fa
ARM_CC
=
arm-linux-gnueabihf-gcc
ARM_PROG
=
main_arm
PROG
=
main
PROG
=
main
SRCDIR
=
../src
SRCDIR
=
../src
...
@@ -15,6 +17,14 @@ CFLAGS += -std=gnu99
...
@@ -15,6 +17,14 @@ CFLAGS += -std=gnu99
vpath
%.c
$(SRCDIR)
vpath
%.c
$(SRCDIR)
$(ARM_PROG)
:
FORCE
make clean
$(
eval
CC:
=
arm-linux-gnueabihf-gcc
)
make
$(PROG)
mv
$(PROG)
$(ARM_PROG)
FORCE
:
$(PROG)
:
$(OBJS)
$(PROG)
:
$(OBJS)
$(CC)
$(LDFLAGS)
$^
-o
$@
$(CC)
$(LDFLAGS)
$^
-o
$@
...
@@ -26,4 +36,4 @@ run: $(PROG)
...
@@ -26,4 +36,4 @@ run: $(PROG)
clean
:
clean
:
$(RM)
$(OBJS)
$(PROG)
$(
subst
.c,.d,
$(SRCS)
)
$(RM)
$(OBJS)
$(PROG)
$(
subst
.c,.d,
$(SRCS)
)
.PHONY
:
clean
.PHONY
:
clean
FORCE
simple-client/build/main_arm
View file @
2c4701fa
No preview for this file type
simple-client/src/main.c
View file @
2c4701fa
...
@@ -3,10 +3,15 @@
...
@@ -3,10 +3,15 @@
#include "getip.h"
#include "getip.h"
#include "send_packet.h"
#include "send_packet.h"
int
main
()
{
int
main
(
int
argc
,
char
*
argv
[])
{
if
(
argc
!=
2
)
{
printf
(
"Usage: %s server_ip
\n
"
,
argv
[
0
]);
return
-
1
;
}
for
(
int
i
=
0
;
i
<
100
;
i
++
)
for
(
int
i
=
0
;
i
<
100
;
i
++
)
send_udp_packet
();
send_udp_packet
(
argv
[
1
]
);
return
0
;
return
0
;
}
}
simple-client/src/send_packet.c
View file @
2c4701fa
#include "send_packet.h"
#include "send_packet.h"
/*
#include <netinet/in.h>
#include <stdio.h>
#include <string.h>
#include <sys/socket.h>
#include <sys/types.h>
*/
#include <stdio.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdlib.h>
#include <unistd.h>
#include <unistd.h>
...
@@ -20,10 +12,9 @@
...
@@ -20,10 +12,9 @@
#include <arpa/inet.h>
#include <arpa/inet.h>
#define SERVER_IP "192.168.0.100"
#define SERVER_PORT "50000"
#define SERVER_PORT "50000"
int
send_udp_packet
(
void
)
{
int
send_udp_packet
(
const
char
*
server_ip
)
{
int
status
;
int
status
;
int
sockfd
;
int
sockfd
;
...
@@ -37,7 +28,7 @@ int send_udp_packet(void) {
...
@@ -37,7 +28,7 @@ int send_udp_packet(void) {
hints
.
ai_family
=
AF_UNSPEC
;
hints
.
ai_family
=
AF_UNSPEC
;
hints
.
ai_socktype
=
SOCK_DGRAM
;
hints
.
ai_socktype
=
SOCK_DGRAM
;
status
=
getaddrinfo
(
SERVER_IP
,
SERVER_PORT
,
&
hints
,
&
servinfo
);
status
=
getaddrinfo
(
server_ip
,
SERVER_PORT
,
&
hints
,
&
servinfo
);
if
(
status
!=
0
)
{
if
(
status
!=
0
)
{
fprintf
(
stderr
,
"getaddrinfo: %s
\n
"
,
gai_strerror
(
status
));
fprintf
(
stderr
,
"getaddrinfo: %s
\n
"
,
gai_strerror
(
status
));
printf
(
"getaddrinfo error, exiting...
\n
"
);
printf
(
"getaddrinfo error, exiting...
\n
"
);
...
@@ -66,7 +57,7 @@ int send_udp_packet(void) {
...
@@ -66,7 +57,7 @@ int send_udp_packet(void) {
freeaddrinfo
(
servinfo
);
freeaddrinfo
(
servinfo
);
printf
(
"Sent %d bytes to %s
\n
"
,
bytes_sent
,
SERVER_IP
);
printf
(
"Sent %d bytes to %s
\n
"
,
bytes_sent
,
server_ip
);
close
(
sockfd
);
close
(
sockfd
);
return
0
;
return
0
;
}
}
simple-client/src/send_packet.h
View file @
2c4701fa
#ifndef SEND_PACKET_H
#ifndef SEND_PACKET_H
#define SEND_PACKET_H
#define SEND_PACKET_H
int
send_udp_packet
(
void
);
int
send_udp_packet
(
const
char
*
ip4
);
#endif
#endif
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment