小编Mic*_*ael的帖子

Internet上的Java套接字:ConnectException(操作超时)

我正试图通过互联网打开一个网站的套接字,但不能.大约一分钟后,a ConnectException抛出一声说操作超时.

Socket clientSocket = new Socket(InetAddress.getByName("gmail.com"), 25);
Run Code Online (Sandbox Code Playgroud)

我的计算机连接到路由器,该路由器连接到Internet.我的路由器配置为将所有传入端口25数据定向到本地计算机上的端口2550(192.168.2.2).所以,我想也许如果我在Socket构造函数上设置"本地地址"和"本地端口"参数它可能会工作...但这也给了我一个"操作超时"错误.

Socket clientSocket = new Socket(InetAddress.getByName("gmail.com"), 25, InetAddress.getByName("192.168.2.2"), 2550);
Run Code Online (Sandbox Code Playgroud)

我看到了这个问题,但是想知道是否有人能够对这个问题有所了解.谢谢.

java networking

2
推荐指数
1
解决办法
383
查看次数

骡子3:如何从MuleMessage获取HTTP头

给定一个MuleMessage从HTTP请求创建的对象,如何获取请求的HTTP头?我正在使用Mule 3.2.1.谢谢.

java mule

2
推荐指数
2
解决办法
9338
查看次数

"匹配"语句中"使用部分移动的值"错误

我的代码:

fn main() {
    let mut messages = vec![];

    let msg = Message::Write{message: "msg".to_string()};
    match msg {
        Message::Write{message} => println!("{}", message),
    };

    messages.push(msg);
}

enum Message {
    Write{message: String},
}
Run Code Online (Sandbox Code Playgroud)

错误:

error: use of partially moved value: `msg` [--explain E0382]
   --> <anon>:9:19
6   |>         Message::Write{message} => println!("{}", message),
    |>                        ------- value moved here
...
9   |>     messages.push(msg);
    |>                   ^^^ value used here after move
note: move occurs because `msg.message` has type `std::string::String`, which does not implement the `Copy` trait

error: …
Run Code Online (Sandbox Code Playgroud)

rust

2
推荐指数
1
解决办法
1462
查看次数

骡子3:为"http:rest-service-component"设置响应超时值

我有一个使用该http:rest-service-component组件的流程.我想要调用的URL大约需要一分钟才能返回响应,但"http:rest-service-component"只等待10秒.

如何更改此超时值?该http:rest-service-component元素没有任何类型的超时属性.我也尝试创建一个"http:connector"并在那里设置超时值,但这不起作用.谢谢.

<flow name="theFlow">
  <inbound-endpoint ... />
  <http:rest-service-component serviceUrl="..." />
</flow>
Run Code Online (Sandbox Code Playgroud)

mule

1
推荐指数
1
解决办法
6046
查看次数

使用针对大型表的远程WHERE子句优化SQL查询

我有一个包含三列的数据库表:ID,时间戳和字符串.每天大约插入14,000行,因此表格非常大.它目前有130万行.

表定义:

CREATE TABLE readings (
  id int primary key auto_increment,
  ts datetime not null, --the timestamp
  json text not null --the string
);
Run Code Online (Sandbox Code Playgroud)

我正在运行的查询是:

SELECT * FROM readings WHERE ts >= 'TIME_START' AND ts <= 'TIME_END' ORDER BY ts
Run Code Online (Sandbox Code Playgroud)

查询大约需要45秒才能执行.如何修改表和/或查询以使其更快?

谢谢.

sql

1
推荐指数
1
解决办法
260
查看次数

在PHP中调用类的任何方法时自动调用方法

我有一个ORM类型的类,我用它来更新数据库中的行.当我将此类的对象传递给我的DAO时,我希望DAO只更新更改的对象中的字段(SQL查询应该只包含更改的列).现在我只是跟踪每次调用setter方法并使用它来确定哪些字段发生了变化.

但这意味着我必须在每个setter方法中复制相同的代码.在PHP中是否有一种方法可以创建一个方法,可以在调用类中的任何方法时自动调用该方法?该__call魔术方法仅适用于不存在的方法.我想要这样的东西,但对于现有的方法.

这是我到目前为止的代码:

class Car{
  private $id;
  private $make;
  private $model;

  private $modifiedFields = array();

  public function getMake(){ return $this->make; }

  public function setMake($make){
    $this->make = $make;
    $this->modified(__METHOD__);
  }

  //getters and setters for other fields

  private function modified($method){
    if (preg_match("/.*?::set(.*)/", $method, $matches)){
      $field = $matches[1];
      $field[0] = strtolower($field[0]);
      $this->modifiedFields[] = $field;
    }
  }
}
Run Code Online (Sandbox Code Playgroud)

这就是我要的:

class Car{
  private $id;
  private $make;
  private $model;

  private $modifiedFields = array();

  public function getMake(){ return $this->make; }

  public function setMake($make){
    //the "calledBeforeEveryMethodCall" …
Run Code Online (Sandbox Code Playgroud)

php

0
推荐指数
1
解决办法
1502
查看次数

无法返回Chars迭代器,因为它"活不够久"

我希望能够将一个Chars迭代器分配给一个结构,String该结构是在struct的"constructor"方法中创建的.我该怎么做呢?

代码(运行它):

use std::str::Chars;

fn main() {
    let foo = Foo::new();
}

struct Foo<'a> {
    chars: Chars<'a>
}
impl<'a> Foo<'a> {
    pub fn new() -> Self {
        let s = "value".to_string();
        Foo { chars: s.chars() }
    }
}
Run Code Online (Sandbox Code Playgroud)

错误:

error: `s` does not live long enough
  --> <anon>:13:22
13 |>         Foo { chars: s.chars() }
   |>                      ^
note: reference must be valid for the lifetime 'a as defined on the block at 11:25...
  --> …
Run Code Online (Sandbox Code Playgroud)

rust

-2
推荐指数
1
解决办法
112
查看次数

标签 统计

java ×2

mule ×2

rust ×2

networking ×1

php ×1

sql ×1