我可以从node.js设置ulimit吗?(Can I set ulimit from node.js?)

我想限制子进程写太多的数据或占用太多CPU时间(无限循环)。 在C中,我会调用setrlimit(2)来做到这一点。 在node.js中是否有这样的东西?


I'd like to restrict child processes from writing too much data or taking up too much cpu time (infinite loop). In C, I'd call setrlimit(2) to do that. Is there something like this in node.js?


原文:https://stackoverflow.com/questions/8141057
2023-04-24 15:04

满意答案

在服务器端调用close()flush()

public static int PLAYER1 = 1;
ObjectOutputStream oos = new ObjectOutputStream(player1.getOutputStream());
oos.writeInt(PLAYER1);

oos.flush();

// OR

oos.close();

flush()将发送已写入客户端的任何数据。 这将使您可以重用oos

如果你不再需要oos ,请调用close() 。 调用close()将刷新尚未发送的任何数据。


Call close() or flush() on server side:

public static int PLAYER1 = 1;
ObjectOutputStream oos = new ObjectOutputStream(player1.getOutputStream());
oos.writeInt(PLAYER1);

oos.flush();

// OR

oos.close();

flush() will send any data already written to the client. This will leave you the possibility to reuse oos.

If you don't need oos anymore, call close(). Calling close() will flush any data not already sent.

相关问答

更多

ObjectInputStream的(socket.getInputStream());(ObjectInputStream(socket.getInputStream()); does not work)

ObjectInputStream构造函数从给定的InputStream中读取数据。 为了实现此目的,在尝试打开ObjectInputStream之前, 必须在构造之后立即刷新ObjectOutputStream(以写入初始标题)。 另外,如果您想要为每个连接发送多个对象,则必须打开一次ObjectOutputStream,并在套接字的生命周期中使用它(例如,您的shareToAll方法)。 the ObjectInputStream constructor reads data from the...

TCP Socket使用Android服务。(TCP Socket using Android service. how can i declare stream objects in MainActivity)

1.是否可以使用服务的Socket对象(clientsocket)在MainActivity中创建PrintWriter对象? 您可以使用messager并将您的对象从服务发送到活动。 看到这个将数据从服务发送到活动: 将服务中的JSON数据发送到Android中的UI 2.是否可以将值从MainActivity传递到服务(即IP地址和端口)? 是的,您可以通过意图传递ip / port并将其置于onStartcomant服务中 即 i.putExtra(name, value); i.getS...

Java - 如何从Socket更新JProgressBar?(Java - How to update JProgressBar from Socket?)

只需使用javax.swing.ProgressMonitorInputStream 。 是否所有努力工作都适合你。 Just use a javax.swing.ProgressMonitorInputStream. Does all the hard work for you.

Stream Socket错误处理winRT(Stream Socket error handling winRT)

您正在获取AggregateException因为它是从async方法生成的 所以是的,你必须检查InnerException的HResult SocketErrorStatus socketErrorStatus = SocketError.GetStatus(ex.InnerException.HResult); 这将为您提供所需的输出。 You are getting an AggregateException since it's being generated from an asyn...

Unity处理来自Socket的数据流(Unity Processing Data Stream from Socket)

整个代码很乱。 您应该使用Thread而不是Async来完成更少的代码。 任何方式,替换byte[] bufferCopy = (byte[])buffer.Clone(); 代码行 byte[] bufferCopy = new byte[buffer.Length]; System.Buffer.BlockCopy(buffer, 0, bufferCopy, 0, bufferCopy.Length); 而对于ProcessFrame((byte[])state.buffer.Clone(...

Java Socket - 通过对象流传递int?(Java Socket - passing int through object stream?)

在服务器端调用close()或flush() : public static int PLAYER1 = 1; ObjectOutputStream oos = new ObjectOutputStream(player1.getOutputStream()); oos.writeInt(PLAYER1); oos.flush(); // OR oos.close(); flush()将发送已写入客户端的任何数据。 这将使您可以重用oos 。 如果你不再需要oos ,请调用close() ...

如何通过套接字发送套接字详细信息[关闭](How to send Socket details through a Socket [closed])

你有解决方案。 如果你(服务器)有2个打开的套接字,一个来自A,另一个来自B,你所要做的就是: 从A读取的内容将其发送给B,从B读取的内容将其发送给A. 当套接字A或套接字B关闭(或有错误)时,您(服务器)关闭两个套接字并且会话结束。 要处理这种情况,您需要使用select或其他非阻塞机制来查看哪个套接字具有要读取的数据并采取相应的操作。 我建议使用一个单独的线程来完成这项工作,这样服务器就可以免费参加更多的客户。 You have the solution at your hand. If yo...

Java Socket Listener问题?(Java Socket Listener Issue?)

这可能是因为循环永远不会停止: while(true) { //code 你可以使用我为java服务器和客户端制作的类: ChatCleint package com.weebly.foxgenesis.src; import java.net.*; import java.io.*; public final class ChatClient { private Socket socket = null; private DataOutput...

需要通过Socket获得字节帮助(Need help on bytes via Socket)

Read对发送的内容一无所知; TCP基本上只是一个流 - 所以没有什么可以说你在一次调用Read拥有所有数据; 你可以有: 确切地说,您发送的数据量 一条消息的一部分 17条消息 一条消息的结束和下一条消息的开始 消息中的1个单独字节 您需要设计某种帧协议,让接收者知道他们何时拥有整个消息。 这可能像长度前缀一样简单,也可能更复杂。 然后,您应该将数据缓冲在内存中(或逐步处理),直到您拥有整个消息。 对Read一次调用不太可能代表单个完整的消息。 实际上,如果消息大于newstate.buffe...

使用Socket的PHP到Java(PHP to Java using Socket)

确定发现了问题,你必须在php中显示行结束的位置,以便套接字可以发送它,它将像魅力一样工作:) socket_write ($my_socket, $data."\r\n", strlen ($data."\r\n")); ok found the problem, you have to show where is the end of the line in php so the socket could send it, and it will work like a charm :) ...

相关文章

更多

Node.js视频教程

捷训Node.js入门教学视频,对初学者来说应该不错的,教学视频中包括javascript的基本知识的 ...

7月最新发布11.2.0.1.2 Patch set update

7月13日,11g release 2 的第二个补丁集更新发布了;9i的最终版本为9.2.0.8,10 ...

Hadoop的I/O

1. 数据完整性:任何语言对IO的操作都要保持其数据的完整性。Hadoop当然希望数据在存储和处理中不 ...

How to set up Solr on Ubuntu 10.04 (or whatever)

How to set up Solr on Ubuntu 10.04 (or whatever) | ...

I18n的一个问题

升级了,2.2.2, 用了I18n. 问题来了。 以前model validation 出错的默认消 ...

最新问答

更多

获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)

我用Google搜索了一个解决方案。 “EnumDisplayModeProvider”是我自己设置网站的各种模式的枚举。 public EnumDisplayModeProvider GetDisplayModeId() { foreach (var mode in DisplayModeProvider.Instance.Modes) if (mode.CanHandleContext(HttpContext)) {

如何通过引用返回对象?(How is returning an object by reference possible?)

这相对简单:在类的构造函数中,您可以分配内存,例如使用new 。 如果你制作一个对象的副本,你不是每次都分配新的内存,而是只复制指向原始内存块的指针,同时递增一个也存储在内存中的引用计数器,使得每个副本都是对象可以访问它。 如果引用计数降至零,则销毁对象将减少引用计数并仅释放分配的内存。 您只需要一个自定义复制构造函数和赋值运算符。 这基本上是共享指针的工作方式。 This is relatively easy: In the class' constructor, you allocate m

矩阵如何存储在内存中?(How are matrices stored in memory?)

正如它在“熵编码”中所说的那样,使用Z字形图案,与RLE一起使用,在许多情况下,RLE已经减小了尺寸。 但是,据我所知,DCT本身并没有给出稀疏矩阵。 但它通常会增强矩阵的熵。 这是compressen变得有损的点:输入矩阵用DCT传输,然后量化量化然后使用霍夫曼编码。 As it says in "Entropy coding" a zig-zag pattern is used, together with RLE which will already reduce size for man

每个请求的Java新会话?(Java New Session For Each Request?)

你是如何进行重定向的? 您是否事先调用了HttpServletResponse.encodeRedirectURL()? 在这里阅读javadoc 您可以使用它像response.sendRedirect(response.encodeRedirectURL(path)); The issue was with the path in the JSESSIONID cookie. I still can't figure out why it was being set to the tomca

css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)

我认为word-break ,如果你想在一个单词中打破行,你可以指定它,这样做可以解决问题: .column { word-break:break-all; } jsFiddle演示。 您可以在此处阅读有关word-break属性的更多信息。 I think word-break, with which you can specify if you want to break line within a word, will do the trick: .column { word-break

无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)

我认为您忘记在分类时间内缩放输入图像,如train_test.prototxt文件的第11行所示。 您可能应该在C ++代码中的某个位置乘以该因子,或者使用Caffe图层来缩放输入(请查看ELTWISE或POWER图层)。 编辑: 在评论中进行了一次对话之后,结果发现在classification.cpp文件中错误地删除了图像均值,而在原始训练/测试管道中没有减去图像均值。 I think you have forgotten to scale the input image during cl

xcode语法颜色编码解释?(xcode syntax color coding explained?)

转到: Xcode => Preferences => Fonts & Colors 您将看到每个语法高亮颜色旁边都有一个简短的解释。 Go to: Xcode => Preferences => Fonts & Colors You'll see that each syntax highlighting colour has a brief explanation next to it.

在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)

你考虑过第三方拼写检查吗? 您可以将在C#中开发的自定义WinForms控件插入访问数据库吗? VB6控件怎么样? 如果你能找到一个使用第三方库进行拼写检查的控件,那可能会有效。 Have you considered a third party spell checker? Can you insert a custom WinForms controls developed in C# into an access database? What about a VB6 control? If

从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)

我有同样的问题,因为我在远程服务器上有两个图像,我需要在每天的预定义时间复制到我的本地服务器,这是我能够提出的代码... try { if(@copy('url/to/source/image.ext', 'local/absolute/path/on/server/' . date("d-m-Y") . ".gif")) { } else { $errors = error_get_last(); throw new Exception($err

从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))

我不确定我完全明白你在说什么。 你能编辑你的帖子并包含你正在做的Subversion命令/操作的特定顺序吗? 最好使用命令行svn客户端,以便容易为其他人重现问题。 如果您只是想获取文件的旧副本(即使该文件不再存在),您可以使用如下命令: svn copy ${repo}/trunk/moduleA/file1@${rev} ${repo}/trunk/moduleB/file1 其中${repo}是您的存储库的URL, ${rev}是您想要的文件的版本。 这将恢复该文件的旧版本,包括最高版本