Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Synchronet
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Main
Synchronet
Commits
323e81ca
Commit
323e81ca
authored
22 years ago
by
rswindell
Browse files
Options
Downloads
Patches
Plain Diff
Fixed UDP support by binding client socket to local address and port.
parent
534a11f4
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/sbbs3/services.c
+40
-12
40 additions, 12 deletions
src/sbbs3/services.c
with
40 additions
and
12 deletions
src/sbbs3/services.c
+
40
−
12
View file @
323e81ca
...
...
@@ -998,6 +998,7 @@ void DLLCALL services_thread(void* arg)
int
udp_len
;
int
i
;
int
result
;
int
optval
;
ulong
total_clients
;
time_t
t
;
time_t
initialized
=
0
;
...
...
@@ -1234,7 +1235,7 @@ void DLLCALL services_thread(void* arg)
if
((
udp_buf
=
(
BYTE
*
)
calloc
(
1
,
MAX_UDP_BUF_LEN
))
==
NULL
)
{
lprintf
(
"%04d %s !ERROR %d allocating UDP buffer"
,
service
[
i
].
socket
,
service
[
i
].
protocol
,
errno
);
break
;
continue
;
}
udp_len
=
recvfrom
(
service
[
i
].
socket
...
...
@@ -1244,7 +1245,7 @@ void DLLCALL services_thread(void* arg)
FREE_AND_NULL
(
udp_buf
);
lprintf
(
"%04d %s !ERROR %d recvfrom failed"
,
service
[
i
].
socket
,
service
[
i
].
protocol
,
ERROR_VALUE
);
break
;
continue
;
}
if
((
client_socket
=
open_socket
(
SOCK_DGRAM
))
...
...
@@ -1252,7 +1253,40 @@ void DLLCALL services_thread(void* arg)
FREE_AND_NULL
(
udp_buf
);
lprintf
(
"%04d %s !ERROR %d opening socket"
,
service
[
i
].
socket
,
service
[
i
].
protocol
,
ERROR_VALUE
);
break
;
continue
;
}
lprintf
(
"%04d %s created client socket: %d"
,
service
[
i
].
socket
,
service
[
i
].
protocol
,
client_socket
);
/* We need to set the REUSE ADDRESS socket option */
optval
=
TRUE
;
if
(
setsockopt
(
client_socket
,
SOL_SOCKET
,
SO_REUSEADDR
,(
char
*
)
&
optval
,
sizeof
(
optval
))
!=
0
)
{
FREE_AND_NULL
(
udp_buf
);
lprintf
(
"%04d %s !ERROR %d setting socket option"
,
client_socket
,
service
[
i
].
protocol
,
ERROR_VALUE
);
close_socket
(
client_socket
);
continue
;
}
memset
(
&
addr
,
0
,
sizeof
(
addr
));
addr
.
sin_addr
.
s_addr
=
htonl
(
startup
->
interface_addr
);
addr
.
sin_family
=
AF_INET
;
addr
.
sin_port
=
htons
(
service
[
i
].
port
);
if
(
startup
->
seteuid
!=
NULL
)
startup
->
seteuid
(
FALSE
);
result
=
bind
(
client_socket
,
(
struct
sockaddr
*
)
&
addr
,
sizeof
(
addr
));
if
(
startup
->
seteuid
!=
NULL
)
startup
->
seteuid
(
TRUE
);
if
(
result
!=
0
)
{
FREE_AND_NULL
(
udp_buf
);
lprintf
(
"%04d %s !ERROR %d re-binding socket to port %u"
,
client_socket
,
service
[
i
].
protocol
,
ERROR_VALUE
,
service
[
i
].
port
);
close_socket
(
client_socket
);
continue
;
}
/* Set client address as default addres for send/recv */
...
...
@@ -1261,16 +1295,10 @@ void DLLCALL services_thread(void* arg)
FREE_AND_NULL
(
udp_buf
);
lprintf
(
"%04d %s !ERROR %d connect failed"
,
client_socket
,
service
[
i
].
protocol
,
ERROR_VALUE
);
break
;
close_socket
(
client_socket
);
continue
;
}
#if 0
if(send(client_socket,"test\r\n",6,0)!=6) {
FREE_AND_NULL(udp_buf);
lprintf("%04d %s !SEND TEST ERROR %d"
,client_socket, service[i].protocol, ERROR_VALUE);
break;
}
#endif
}
else
{
/* TCP */
if
((
client_socket
=
accept
(
service
[
i
].
socket
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment