问题列表 - 第11767页

在Erlang中确定传入TCP/IP连接的IP地址和端口

我想获取传入的TCP/IP连接的IP地址和端口号.不幸gen_tcpacceptrecv函数只给回一个插座,而gen_udprecv功能也给后面的地址信息.是否有一种直接的方法来收集属于Erlang中的套接字的地址信息?

sockets erlang tcp

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

为什么List <Number>不是List <Object>的子类型?

public void wahey(List<Object> list) {}

wahey(new LinkedList<Number>());
Run Code Online (Sandbox Code Playgroud)

对方法的调用不会进行类型检查.我甚至无法将参数强制转换如下:

wahey((List<Object>) new LinkedList<Number>());
Run Code Online (Sandbox Code Playgroud)

根据我的研究,我收集到不允许这样做的原因是类型安全.如果允许我们执行上述操作,那么我们可以执行以下操作:

List<Double> ld;
wahey(ld);
Run Code Online (Sandbox Code Playgroud)

在方法wahey中,我们可以在输入列表中添加一些字符串(因为参数维护List<Object>引用).现在,在方法调用之后,ld引用一个带有类型的列表List<Double>,但实际列表包含一些String对象!

这似乎与没有泛型的Java正常工作方式不同.例如:

Object o;
Double d;
String s;

o = s;
d = (Double) o;
Run Code Online (Sandbox Code Playgroud)

我们在这里做的基本上是相同的,除了这将通过编译时检查,并且只在运行时失败.带有列表的版本将无法编译.

这让我相信这纯粹是关于泛型类型限制的设计决策.我希望对这个决定有所评论?

java generics casting covariance

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

当部分本地人作为自己的本地发送给另一个部分时,它不会持久存在

我像这样渲染部分:

<%= render :partial => 'widgets/some_partial, :locals => {:foo => 'bar'} %>
Run Code Online (Sandbox Code Playgroud)

所以_some_partial.html.erb我在里面渲染了两个更像的部分:

<% #foo.nil? #=> false %>
<%= render :partial => 'widgets/another_partial', :locals => {:foo => foo} %>
`<%= render :partial => 'widgets/another_partial_again', :locals => {:foo => foo} %>`
Run Code Online (Sandbox Code Playgroud)

foo局部变量渲染得很好some_partial.html.erb甚至在another_partial_again.html.erb.但是,another_partial.html.erb即使我在render调用中明确地传递了foo变量,foo变量也是不可访问的.

这里发生了什么?

谢谢您的帮助.

ruby-on-rails local-variables partial

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

在PHP中引用容器对象的方法?

在PHP中给出以下内容:

<?php
class foo {
  public $bar;
  function __construct() {
    "Foo Exists!";
  }

  function magic_bullet($id) {
    switch($id) {
    case 1:
      echo "There is no spoon! ";
    case 2:
      echo "Or is there... ";
      break;
    }
  }
}

class bar {
  function __construct() {
    echo "Bar exists";
  }
  function target($id) {
    echo "I want a magic bullet for this ID!";
  }
}

$test = new foo();
$test->bar = new bar();
$test->bar->target(42);
Run Code Online (Sandbox Code Playgroud)

我想知道'bar'类是否可以调用'foo'类的'magic bullet'方法.'bar'实例包含在'foo'实例中,但与它没有父/子关系.实际上,我有很多不同的"条形"类,"foo"在一个数组中,每个类都有一些与$ id不同的东西,然后想要将它传递给"magic_bullet"函数以获得最终结果,所以禁止结构更改类关系,是否可以访问"容器"实例的方法?

php

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

安装.NET Windows服务

我正在尝试安装我编写的第一个服务:

installutil XMPPMonitor.exe
Run Code Online (Sandbox Code Playgroud)

我收到以下消息:

Running a transacted installation.

Beginning the Install phase of the installation.
See the contents of the log file for the E:\Documents\Projects\XMPPMonitor\XMPPMonitor\bin\Debug\XMPPMonitor.exe assembly's progress.
The file is located at E:\Documents\Projects\XMPPMonitor\XMPPMonitor\bin\Debug\XMPPMonitor.InstallLog.

The Install phase completed successfully, and the Commit phase is beginning.
See the contents of the log file for the E:\Documents\Projects\XMPPMonitor\XMPPMonitor\bin\Debug\XMPPMonitor.exe assembly's progress.
The file is located at E:\Documents\Projects\XMPPMonitor\XMPPMonitor\bin\Debug\XMPPMonitor.InstallLog.

The Commit phase completed successfully.


The transacted install has completed.
Run Code Online (Sandbox Code Playgroud)

但我没有设置运行 services.msc 时列出的服务。我错过了什么吗?

.net c#

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

按按钮从应用程序打开网页

我有一个应用程序,我想与网页进行交互.基本上我想按一个按钮,网页将以新视图打开...

对不起,我不清楚,我正在Mac上为iPhone开发.目前我有一个"找到我"应用程序,显示您的纬度和经度.我想使用这些变量来填充我开发的PHP网页/表单中的2个空白.

我在当前的应用程序中添加了一个标签和按钮,当按下按钮时,标签中会显示带有Lat和Long(作为传递的vars)的URL.我希望这些变量出现在我的网页上.希望这更清楚......


解决: 我刚刚添加了这里找到的代码行:

NSURL *url = [ [ NSURL alloc ] initWithString: @"http://www.cnn.com" ];

[[UIApplication sharedApplication] openURL:url];
Run Code Online (Sandbox Code Playgroud)

iphone xcode webpage

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

577
推荐指数
13
解决办法
55万
查看次数

检查转换为数字的字符串是否实际上是actionscript中的数字的最简单方法

不确定这是否有意义,但我需要检查返回的服务器值是否实际上是一个数字.现在我将所有数字值作为字符串返回,即'7'而不是7.

检查字符串值是否可以实际转换为数字的最简单方法是什么?

apache-flex flash

14
推荐指数
3
解决办法
4万
查看次数

存储Java系统包的位置在哪里?

我想看看所有的java包.包裹存放在我的机器中的哪个位置?谁能帮忙.我在jdk文件夹中搜索并找到了awt.dll和all.但它只有少数几个.我可以看到他们所有人吗?

java packages file-structure

13
推荐指数
4
解决办法
4万
查看次数

从JavaScript字符串中读取字节

我有一个包含JavaScript中二进制数据的字符串.现在我想从中读取一个整数.所以我得到前4个字符,使用charCodeAt,做一些移位等等来得到一个整数.

问题是JavaScript中的字符串是UTF-16(而不是ASCII),并且charCodeAt通常返回高于256的值.

Mozilla的参考指出,"前128个Unicode码点是ASCII字符编码的直接匹配".(那么ASCII值> 128?).

如何将结果转换为charCodeAtASCII值?或者有更好的方法将四个字符的字符串转换为4字节整数?

javascript

32
推荐指数
6
解决办法
7万
查看次数