Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
GnssServer
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
zhushanglei
GnssServer
Commits
a8bd4079
Commit
a8bd4079
authored
Apr 06, 2022
by
zhushanglei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
init
parent
fffed4bb
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
13 deletions
+15
-13
TcpServer.java
src/main/java/server/TcpServer.java
+14
-13
config.properties
src/main/resources/config.properties
+1
-0
No files found.
src/main/java/server/TcpServer.java
View file @
a8bd4079
...
@@ -81,19 +81,20 @@ public class TcpServer {
...
@@ -81,19 +81,20 @@ public class TcpServer {
InetAddress
addr
=
InetAddress
.
getLocalHost
();
InetAddress
addr
=
InetAddress
.
getLocalHost
();
logger
.
info
(
"Local HostAddress:"
+
addr
.
getHostAddress
());
logger
.
info
(
"Local HostAddress:"
+
addr
.
getHostAddress
());
String
hostname
=
addr
.
getHostName
();
String
hostname
=
addr
.
getHostName
();
byte
[]
mac
=
NetworkInterface
.
getByInetAddress
(
addr
).
getHardwareAddress
();
// byte[] mac = NetworkInterface.getByInetAddress(addr).getHardwareAddress();
//
StringBuffer
sb
=
new
StringBuffer
();
// StringBuffer sb = new StringBuffer();
for
(
int
i
=
0
;
i
<
mac
.
length
;
i
++)
{
// for (int i = 0; i < mac.length; i++) {
if
(
i
!=
0
)
{
// if (i != 0) {
sb
.
append
(
"-"
);
// sb.append("-");
}
// }
// mac[i] & 0xFF 是为了把byte转化为正整数
// // mac[i] & 0xFF 是为了把byte转化为正整数
String
s
=
Integer
.
toHexString
(
mac
[
i
]
&
0xFF
);
// String s = Integer.toHexString(mac[i] & 0xFF);
sb
.
append
(
s
.
length
()
==
1
?
0
+
s
:
s
);
// sb.append(s.length() == 1 ? 0 + s : s);
}
// }
deviceId
=
sb
.
toString
();
// deviceId = sb.toString();
logger
.
info
(
"mac: "
+
sb
.
toString
());
// logger.info("mac: "+sb.toString());
deviceId
=
hostname
;
logger
.
info
(
"Local host name: "
+
hostname
);
logger
.
info
(
"Local host name: "
+
hostname
);
b
.
bind
(
addr
.
getHostAddress
(),
PORT
).
sync
();
b
.
bind
(
addr
.
getHostAddress
(),
PORT
).
sync
();
// b.bind(IP, PORT).sync();
// b.bind(IP, PORT).sync();
...
...
src/main/resources/config.properties
0 → 100644
View file @
a8bd4079
serverUrl
:
http://192.168.0.111:8001/gps
\ No newline at end of file
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