Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
T
traffic-signal-platform
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
signal
traffic-signal-platform
Commits
1f4db17f
Commit
1f4db17f
authored
May 16, 2023
by
duanruiming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[update] 绑定本地固定端口
parent
6889e078
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
3 deletions
+9
-3
NettyClient.java
...ervice/src/main/java/net/wanji/com/netty/NettyClient.java
+4
-3
NettyServerHandler.java
.../java/net/wanji/com/netty/handler/NettyServerHandler.java
+5
-0
No files found.
signal-utc-dt-service/src/main/java/net/wanji/com/netty/NettyClient.java
View file @
1f4db17f
...
...
@@ -41,8 +41,9 @@ public class NettyClient {
bootstrap
.
group
(
group
)
.
channel
(
NioDatagramChannel
.
class
)
.
option
(
ChannelOption
.
RCVBUF_ALLOCATOR
,
new
FixedRecvByteBufAllocator
(
65535
))
.
localAddress
(
5051
)
.
remoteAddress
(
new
InetSocketAddress
(
"10.102.1.204"
,
5050
))
// .localAddress(new InetSocketAddress(5051))
// 绑定bending端口
.
remoteAddress
(
new
InetSocketAddress
(
5051
))
.
handler
(
new
ChannelInitializer
<
NioDatagramChannel
>()
{
@Override
protected
void
initChannel
(
NioDatagramChannel
datagramChannel
)
{
...
...
@@ -50,7 +51,7 @@ public class NettyClient {
.
addLast
(
new
NettyServerHandler
(
threadPoolExecutor
));
}
});
ChannelFuture
channelFuture
=
bootstrap
.
bind
().
sync
();
ChannelFuture
channelFuture
=
bootstrap
.
bind
(
5050
).
sync
();
Runtime
.
getRuntime
().
addShutdownHook
(
new
Thread
(()
->
{
group
.
shutdownGracefully
();
channelFuture
.
channel
().
closeFuture
().
syncUninterruptibly
();
...
...
signal-utc-dt-service/src/main/java/net/wanji/com/netty/handler/NettyServerHandler.java
View file @
1f4db17f
...
...
@@ -81,6 +81,11 @@ public class NettyServerHandler extends SimpleChannelInboundHandler<DatagramPack
}
}
@Override
public
void
exceptionCaught
(
ChannelHandlerContext
ctx
,
Throwable
cause
)
throws
Exception
{
super
.
exceptionCaught
(
ctx
,
cause
);
}
private
CommandPojo
getCommandPojo
(
String
key
,
String
data
)
{
CrossInfoPO
crossInfo
=
crossInfoCache
.
getCrossInfo
(
key
);
CommandPojo
commandPojo
=
new
CommandPojo
();
...
...
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