我创建了一个 Linux Azure VM。我想将跟踪路由从它发送到我的家庭 IP 地址。然而,traceroute 在每一跳上都会超时。我已将虚拟机配置为具有公共静态 IP 地址。并为所有端口制定入站和出站规则。
有谁知道还需要配置什么才能成功发送跟踪路由?
一个有趣的事实是,跟踪路由在 Windows Server Azure VM 中成功,但在 Linux Ubuntu 16.04 中却失败。
VM 在两种情况下都附加了静态 IP:Linux 和 Windows。
还有一个细节:在 Windows Azure VM 上,前 5 个跃点不会回复,但其他跃点会回复。在 Linux Azure VM 上,每一跳都不会回复。
我正在调用一个外部异步函数,该函数应在完成后调用回调。
但是,由于该函数是外部的,因此我无法控制其实现,并且我想将超时设置为 5 秒作为示例,并考虑如果在这 5 秒内未调用传递给该外部异步函数的回调,则考虑超时操作。秒。
我目前发现的唯一方法是让当前线程休眠,这实际上会阻塞线程。
这是一个例子:
+(void)myFuncWithCompletion:(void (^ _Nonnull)(BOOL))completion{
BOOL timedOut = NO;
BOOL __block finishedAsyncCall = NO;
[someObj someAsyncMethod {
// completion callback
finishedAsyncCall = YES;
if (!timedOut) {
completion(YES);
}
}];
// This is the logic I want to fix. My goal is to make something similar but non-blocking.
long timeoutInSeconds = 5;
long startTime = [[NSDate date] timeIntervalSince1970];
long currTime = [[NSDate date] timeIntervalSince1970];
while (!finishedAsyncCall && startTime + timeoutInSeconds > currTime) {
[NSThread sleepForTimeInterval:0]; …