Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
bytevia
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Michael Pastushkov
bytevia
Commits
cd45d6a9
Commit
cd45d6a9
authored
Sep 17, 2024
by
Michael Pastushkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
udp fork work in progress
parent
6dc78e67
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
18 deletions
+29
-18
run_udp_client
+2
-2
run_udp_server
+2
-2
src/bytevia.c
+25
-14
No files found.
run_udp_client
View file @
cd45d6a9
#!/bin/sh
make clean
&&
make
&&
./bytevia
--local-port
=
1984
--remote-host
=
p4pn.net
--remote-port
=
1948
--proto
=
udp
--secret
=
52341
\ No newline at end of file
make clean
&&
make
&&
./bytevia
--local-port
=
1948
--remote-host
=
p4pn.net
--remote-port
=
1984
--proto
=
udp
--secret
=
52341
--fork
\ No newline at end of file
run_udp_server
View file @
cd45d6a9
#!/bin/sh
make clean
&&
make
&&
./bytevia
--local-port
=
1984
--remote-host
=
127.0.0.1
--remote-port
=
1948
--mode
=
server
--proto
=
udp
--secret
=
52341
\ No newline at end of file
make clean
&&
make
&&
./bytevia
--local-port
=
1984
--remote-host
=
127.0.0.1
--remote-port
=
1948
--mode
=
server
--proto
=
udp
--secret
=
52341
--fork
\ No newline at end of file
src/bytevia.c
View file @
cd45d6a9
...
...
@@ -244,16 +244,24 @@ int wait_connection(void) {
#else
unsigned
int
client_addr_size
;
#endif
if
(
options
.
proto
==
SOCK_DGRAM
)
return
0
;
client_addr_size
=
sizeof
(
struct
sockaddr_in
);
rc
.
client_socket
=
accept
(
rc
.
server_socket
,
(
struct
sockaddr
*
)
&
rc
.
client_addr
,
&
client_addr_size
);
if
(
rc
.
client_socket
<
0
)
{
if
(
errno
!=
EINTR
)
perror
(
"wait_for_clients: accept()"
);
return
1
;
if
(
options
.
proto
==
SOCK_DGRAM
)
{
fd_set
io
;
FD_ZERO
(
&
io
);
FD_SET
(
rc
.
client_socket
,
&
io
);
if
(
select
(
rc
.
client_socket
+
1
,
&
io
,
NULL
,
NULL
,
NULL
)
<
0
)
{
if
(
errno
!=
EINTR
)
perror
(
"wait_connection: select()"
);
return
1
;
}
}
else
{
rc
.
client_socket
=
accept
(
rc
.
server_socket
,
(
struct
sockaddr
*
)
&
rc
.
client_addr
,
&
client_addr_size
);
if
(
rc
.
client_socket
<
0
)
{
if
(
errno
!=
EINTR
)
perror
(
"wait_connection: accept()"
);
return
1
;
}
}
if
(
options
.
client_address
&&
(
strcmp
(
inet_ntoa
(
rc
.
client_addr
.
sin_addr
),
options
.
client_address
)
!=
0
))
{
...
...
@@ -396,11 +404,13 @@ void serve(void) {
#else
if
(
options
.
fork
)
{
if
(
fork
()
==
0
)
{
if
(
options
.
log
)
printf
(
"forking ...
\n
"
);
close
(
rc
.
server_socket
);
run
();
exit
(
0
);
}
close
(
rc
.
client_socket
);
//
close(rc.client_socket);
}
else
{
run
();
...
...
@@ -558,10 +568,10 @@ void check_options() {
}
/* Consistency checkss */
if
(
options
.
proto
==
SOCK_DGRAM
&&
options
.
fork
)
{
printf
(
"%s: %s
\n
"
,
name
,
"option --fork is not supported with --proto=udp, ignored"
);
options
.
fork
=
0
;
}
//
if (options.proto == SOCK_DGRAM && options.fork) {
//
printf("%s: %s\n", name, "option --fork is not supported with --proto=udp, ignored");
//
options.fork = 0;
//
}
if
(
options
.
mode
==
MODE_SERVER
&&
!
options
.
stay_alive
)
{
printf
(
"%s: %s
\n
"
,
name
,
"option --stay-alive is switched on with --mode=server"
);
options
.
stay_alive
=
0
;
...
...
@@ -638,6 +648,7 @@ int main(int argc, char *argv[]) {
printf
(
" remote: %s:%d
\n
"
,
options
.
remote_host
,
options
.
remote_port
);
printf
(
" mode: %s
\n
"
,
options
.
mode
==
MODE_SERVER
?
"server"
:
"client"
);
printf
(
" encrypt: %s
\n
"
,
options
.
encrypt
?
"yes"
:
"no"
);
printf
(
" fork: %s
\n
"
,
options
.
fork
?
"yes"
:
"no"
);
}
do
...
...
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