- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个迷你监听器/守护程序来捕获 SNMP 陷阱。这将在 tomcat7 上运行主项目(spring web)时执行监听器。但我总是得到错误 java.net.BindException: Permission denied
我尝试使用 authbind ( http://java-notes.com/ ),但我的问题没有解决。我也曾尝试将端口更改为更大的端口,但出现错误 java.net.BindException: Cannot assign requested address
这是我的应用程序/陷阱接收器代码:
@Component
public class TrapReceiver extends Thread implements CommandResponder {
@Inject
private ApplicationContext applicationContext;
@Inject
private Executor executor;
public TrapReceiver(){
}
List<PDUv1> listPdu = new ArrayList<PDUv1>();
String message = "";
long totReceivedTrap = 0;
@PostConstruct
public void init() {
System.out.println("Running trap listener");
this.start();
}
public synchronized void processPdu(CommandResponderEvent cmdRespEvent) {
PDUv1 pdu = (PDUv1) cmdRespEvent.getPDU();
listPdu.add(pdu);
if (pdu != null) {
if(listPdu.size() == 10){ //10 trap per thread
List<PDUv1> temp = new ArrayList<PDUv1>();
temp.addAll(listPdu);
TrapInsertor trapInsertor = (TrapInsertor) applicationContext.getBean("trapInsertor");
trapInsertor.setProperty(temp);
executor.execute(trapInsertor);
listPdu.clear();
}
}
}
public void run() {
while (true) {
try {
this.listen(new UdpAddress(getIp()+"/162")); //alamat PDU akan listen
} catch (Exception e) {
e.printStackTrace();
}
}
}
public synchronized void listen(TransportIpAddress address)
throws IOException {
AbstractTransportMapping transport;
if (address instanceof TcpAddress) {
transport = new DefaultTcpTransportMapping((TcpAddress) address);
} else {
transport = new DefaultUdpTransportMapping((UdpAddress) address);
}
ThreadPool threadPool = ThreadPool.create("DispatcherPool", 10);
MessageDispatcher mDispathcher = new MultiThreadedMessageDispatcher(
threadPool, new MessageDispatcherImpl());
// add message processing models
mDispathcher.addMessageProcessingModel(new MPv1());
mDispathcher.addMessageProcessingModel(new MPv2c());
// add all security protocols
SecurityProtocols.getInstance().addDefaultProtocols();
SecurityProtocols.getInstance().addPrivacyProtocol(new Priv3DES());
// Create Target
CommunityTarget target = new CommunityTarget();
target.setCommunity(new OctetString("public"));
Snmp snmp = new Snmp(mDispathcher, transport);
snmp.addCommandResponder(this);
transport.listen();
System.out.println("Listening on " + address);
try {
this.wait();
} catch (InterruptedException ex) {
Thread.currentThread().interrupt();
}
}
//fungsi untuk mendapatkan real ip local (bukan 127.0.0.1)
public static String getIp(){
String ipAddress = null;
Enumeration<NetworkInterface> net = null;
try {
net = NetworkInterface.getNetworkInterfaces();
} catch (SocketException e) {
throw new RuntimeException(e);
}
while(net.hasMoreElements()){
NetworkInterface element = net.nextElement();
Enumeration<InetAddress> addresses = element.getInetAddresses();
while (addresses.hasMoreElements()){
InetAddress ip = addresses.nextElement();
if (ip instanceof Inet4Address){
if (ip.isSiteLocalAddress()){
ipAddress = ip.getHostAddress();
}
}
}
}
return ipAddress;
}
}
最佳答案
您需要成为 root
才能绑定(bind)到 Linux 系统上的低端口。请确保以足够的权限运行您的 Java 应用程序。当连接到高端口时,确保它没有被其他进程/服务使用。
另见 Binding to a Privileged Port on Debian/Ubuntu关于在 Ubuntu 上启用 AUTHBIND
。
关于java - 将低端口绑定(bind)到 Ubuntu 服务器上的 Java 程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30568335/
我的 Linux Centos Apache 服务器的性能有问题。我有一个程序(用 c 语言编写)可以同时执行许多 http 请求。这个过程本身看起来非常有效,就好像我可以同时向外部服务器发出 500
我想知道如何将并行端口上的数据引脚设置为高电平和低电平。我相信我可以使用 PyParallel 来实现此目的,但我不确定如何设置特定的引脚。 谢谢! 最佳答案 您在这里谈论的是软件-硬件接口(inte
让我有一个像这样的日期时间索引的数据框: date_time open high low close vol 2018-05-13 18:00:00 70.
在 emacs Octave 模式下,当我输入 M-x run-octave 时,命令会卡住,所以我使用 C-g 进行转义。我可以用 C-x b 切换到 *Inferior Octave* 缓冲区,但
我正在 sklearn 中运行 gridsearchCV,尝试使用此代码找到最佳模型参数。 modelDNN= KerasRegressor(build_fn=build_DNN_model, epo
美好的一天。我想知道 android 存储是否低,它会影响应用程序性能吗?因为同一个应用程序在另一台设备上运行速度很快,而同样的应用程序在另一台设备上非常滞后,后者有 12GB 内存中的 2GB 可用
所以我在列卡上有一个带有索引的表 当我运行时 SELECT COUNT(DISTINCT(card)) FROM table 它返回 490 个不同的条目 但是当我运行的时候 SHOW INDEXES
我正在使用手动方法将二进制转换为十进制。此代码在最后一位为高的情况下工作正常,例如:1001。当最后一位为零 [低] 时会出现错误。例如:1010 应该给出 10 但给出 5,因为没有考虑最后一位。有
我一直在努力优化我的站点和数据库,并且我一直在使用 mysqltuner.pl 来帮助解决这个问题。除了表缓存命中率,无论我在 my.cnf 中将它提高多高,我几乎都得到了正确的结果,我仍然命中大约
深入研究 sprite kit (xcode 5)。我正在使用两个示例程序,1. 创建新项目时包含的默认宇宙飞船示例和 2. 我下载的 Adventure Game。 在 iOS 模拟器中运行这些示例
编辑: 感谢大家在这里提供答案,项目已完成。 https://github.com/0xyg3n/ProcessDaemon/ 如果有人想出可能会更好的多线程解决方案,我想。 我是 C# 的新手,我想
我有一个交换 Word 变量的字节(低/高)的过程(它与 System.Swap 函数执行相同的操作)。该过程在编译器优化关闭时有效,但在编译器优化打开时无效。有人可以帮我解决这个问题吗? proce
我以前听说过这些术语描述语言,例如 C 并不是一种低级语言,C++是中级语言,而Python是一种高级语言。我知道它必须与代码的编译方式以及代码的编写方式有关。但是我想知道的是,什么将语言定义为这三类
我有一个关于 NoSQL 类型数据库的问题,特别是 MongoDB,但它通常适用于大多数键值或基于文档的存储。 NoSQL 的一些卖点是速度和可扩展性,但在我看来,与关系数据库相比,开销很大。 你有很
如果没有此代码,fps 为 60-65。但是当我使用这段代码时,fps 下降到 50。 另一个问题是某些设备上的 FPS 太低。然而,游戏非常简单。我对所有形状使用 ShapeRenderer。游戏在
您好,我的名字是 Ryan,我目前正在开发自己的 2D java 游戏。目前游戏世界中有很多物体。游戏重新开始时,世界会加载 100 棵随机放置的树木,这些树木是使用数组列表和树类制作的。我的游戏使用
很难说出这里问的是什么。这个问题是含糊的、模糊的、不完整的、过于宽泛的或修辞性的,无法以目前的形式得到合理的回答。如需帮助澄清此问题以便重新打开它,visit the help center 。 已关
我刚刚将我的 Heroku postgres 数据库从 Kappa 计划(800MB RAM,postgres 9.1)升级到 Ronin 计划(1.7GB RAM,postgres 9.2),但性能
现在我正在使用我的 NSDictionary 并运行所有值的循环以找到低值、高值和计算平均值。 由于我是IOS 的新手,所以我想问问是否有更好的方法来做到这一点。有没有? 谢谢。 最佳答案 这个问题的
我目前正在使用 genuino 101 进行一个项目,我需要通过 i2c 读取大量数据,以填充任意大小的缓冲区。从下图中我可以看到读取请求本身只需要大约 3毫秒,写请求大约 200 纳秒。 但是在同一
我是一名优秀的程序员,十分优秀!