问题列表 - 第25359页

带close()套接字的错误文件描述符(c ++)

当程序无法连接其他主机时,我的文件描述符用完了.close()系统调用不起作用,打开套接字的数量增加.我可以用它

cat/proc/sys/fs/file-nr

从控制台打印:

connect:没有到主机的路由

close:错误的文件描述符

connect:没有到主机的路由

close:错误的文件描述符

..

码:

#include <stdio.h>
#include <stdlib.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
#include <string.h>
#include <iostream>
using namespace std;

#define PORT            1238
#define MESSAGE         "Yow!!! Are we having fun yet?!?"
#define SERVERHOST      "192.168.9.101"

void
write_to_server (int filedes)
{
  int nbytes;

  nbytes = write (filedes, MESSAGE, strlen (MESSAGE) + 1);
  if (nbytes < 0)
    {
      perror ("write");
    }
}

void
init_sockaddr (struct sockaddr_in *name,
               const char *hostname,
               uint16_t port)
{
  struct hostent *hostinfo;

  name->sin_family …
Run Code Online (Sandbox Code Playgroud)

c++ sockets file-descriptor

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

按位运算符XOR('^')如何工作?

当我看到以下代码的输出时,我有点困惑:

$x = "a";
$y = "b";
$x ^= $y;
$y ^= $x;
$x ^= $y;
echo $x; //Got b
echo $y; //Got a
Run Code Online (Sandbox Code Playgroud)

操作员如何在^这里工作?

php bitwise-operators

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

Microsoft JScript运行时错误:需要对象

我写了一个简单的javascript函数来验证aspx页面中的字段

function validate()

{
 if (document.getElementById("<%=tbName.ClientID%>").value=="")
  {
             alert("Name Feild can not be blank");
             document.getElementById("<%=tbName.ClientID%>").focus();
             return false;
  }
  if (document.getElementById("<%=ddlBranch.ClientID%>").value=="SelectBranch")
  {
             alert("Branch Should Be Selected");
             document.getElementById("<%=ddlBranch.ClientID%>").focus();
             return false;
  }

}
Run Code Online (Sandbox Code Playgroud)

一切都很好.后来我将它链接到aspx页面,就像一个外部的js文件.

head runat ="server">

script src ="validation.js"type ="text/javascript">

/ SCRIPT>

<title>Validations</title>
Run Code Online (Sandbox Code Playgroud)

/ HEAD>

<form id="form" runat="server">



<asp:Label ID="lblName" runat="server" Text="Nmae: ">/asp:Label>
<asp:TextBox ID="tbName" runat="server" Width="130px">/asp:TextBox>

<asp:Label ID="lblBranch" runat="server" Text="Branch:">/asp:Label>
    <asp:DropDownList ID="ddlBranch" runat="server" Width="107px">
        <asp:ListItem>CSE</asp:ListItem>
        <asp:ListItem>ECE</asp:ListItem>
        <asp:ListItem>CIVIL</asp:ListItem>
        <asp:ListItem>MECH</asp:ListItem>
        <asp:ListItem Selected="True" Value="SelectBranch">SelectBranch</asp:ListItem>
    </asp:DropDownList>    
<asp:Button ID="btnSubmit" runat="server" Text="Submit" OnClientClick="return validate(<%=tbName.ClientID%>, <%=ddlBranch.ClientID%>)" />

</form> 
Run Code Online (Sandbox Code Playgroud)

和 …

javascript

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

Groovy和GWT:结合两种范式

是否可以使用GWT组件在groovy中开发应用程序?

路易斯

groovy gwt

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

为什么我的打印当前日期时间(C语言)给出不同的答案

我想得到当前日期(日,星期一和年).我发现C中有一些函数可以像ctime(获取时间字符串),localtime和gmtime那样执行.我尝试使用以下代码,但输出不同.我得到这个输出:

日期和时间是2010年4月20日星期二(这是正确的)

这一年是:110

这一年是:110.

有人知道为什么吗?

int main(int argc, char** argv)
{   
   time_t now;
   if((now = time(NULL)) == (time_t)-1)
   {
      puts("Failure in getting time");
   }
   else {
      printf("The date and time is: %s\n", ctime(&now));
      printf("The year is: %ld\n", localtime(&now)->tm_year);
      printf("The year is: %ld\n", gmtime(&now)->tm_year);
   }
   getchar();
}
Run Code Online (Sandbox Code Playgroud)

c printf datetime

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

列出对象的属性

有没有办法获取类实例上存在的属性列表?

class new_class():
    def __init__(self, number):
        self.multi = int(number) * 2
        self.str = str(number)

a = new_class(2)
print(', '.join(a.SOMETHING))
Run Code Online (Sandbox Code Playgroud)

期望的结果是将输出"multi,str".我希望这能看到脚本各个部分的当前属性.

python class python-3.x

256
推荐指数
12
解决办法
51万
查看次数

如何查看Google街景视图是否可用并显示消息?

我正在传递lat和lng变量并在div中显示google sreet视图.问题是当StreetView无法使用时,不会显示任何内容.我想检查是否有给定lat和lng的街景并显示消息.这是我的代码:

var myPano = new GStreetviewPanorama(document.getElementById("street2"), panoOpts);
var location = new GLatLng(lat,lng)
myPano.setLocationAndPOV(location);
Run Code Online (Sandbox Code Playgroud)

也许我应该使用类似的东西: Event.addListener(myPano, "error", errorMessage());

有任何想法吗?

javascript google-maps google-street-view

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

正则表达式与C#中的交集匹配

我想知道是否有可能获得所有匹配的MatchCollection,即使它们之间存在交集.

string input = "a a a";
Regex regex = new Regex("a a");
MatchCollection matches = regex.Matches(input);
Console.WriteLine(matches.Count);
Run Code Online (Sandbox Code Playgroud)

此代码返回1,但我希望它返回2.如何实现它?
谢谢您的帮助.

c# regex

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

在SQL数据库中存储没有一年的日期的最佳方法是什么?

我正在构建一个应该存储在数据库中的每日报价的应用程序.每个报价分配一年中的一天,包括2月29日的一天.由于引用只关心那一天不是一年,我还应该使用smalldatetime类型吗?请让我知道你的意见,谢谢!!

.net sql sql-server

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

将列表框绑定到列表<对象>

将Listbox绑定到对象列表的最简单方法是什么?

c# listbox winforms

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