首页 \ 问答 \ 我可以从node.js设置ulimit吗?(Can I set ulimit from node.js?)

我可以从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构造函数从给定的InputStream中读取数据。 为了实现此目的,在尝试打开ObjectInputStream之前, 必须在构造之后立即刷新ObjectOutputStream(以写入初始标题)。 另外,如果您想要为每个连接发送多个对象,则必须打开一次ObjectOutputStream,并在套接字的生命周期中使用它(例如,您的shareToAll方法)。 the ObjectInputStream constructor reads data from the give ...
  • 1.是否可以使用服务的Socket对象(clientsocket)在MainActivity中创建PrintWriter对象? 您可以使用messager并将您的对象从服务发送到活动。 看到这个将数据从服务发送到活动: 将服务中的JSON数据发送到Android中的UI 2.是否可以将值从MainActivity传递到服务(即IP地址和端口)? 是的,您可以通过意图传递ip / port并将其置于onStartcomant服务中 即 i.putExtra(name, value); i.getString ...
  • 只需使用javax.swing.ProgressMonitorInputStream 。 是否所有努力工作都适合你。 Just use a javax.swing.ProgressMonitorInputStream. Does all the hard work for you.
  • 您正在获取AggregateException因为它是从async方法生成的 所以是的,你必须检查InnerException的HResult SocketErrorStatus socketErrorStatus = SocketError.GetStatus(ex.InnerException.HResult); 这将为您提供所需的输出。 You are getting an AggregateException since it's being generated from an async met ...
  • 整个代码很乱。 您应该使用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()); , ...
  • 在服务器端调用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() 。 调用c ...
  • 你有解决方案。 如果你(服务器)有2个打开的套接字,一个来自A,另一个来自B,你所要做的就是: 从A读取的内容将其发送给B,从B读取的内容将其发送给A. 当套接字A或套接字B关闭(或有错误)时,您(服务器)关闭两个套接字并且会话结束。 要处理这种情况,您需要使用select或其他非阻塞机制来查看哪个套接字具有要读取的数据并采取相应的操作。 我建议使用一个单独的线程来完成这项工作,这样服务器就可以免费参加更多的客户。 You have the solution at your hand. If you (th ...
  • 这可能是因为循环永远不会停止: 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 DataOutputStrea ...
  • Read对发送的内容一无所知; TCP基本上只是一个流 - 所以没有什么可以说你在一次调用Read拥有所有数据; 你可以有: 确切地说,您发送的数据量 一条消息的一部分 17条消息 一条消息的结束和下一条消息的开始 消息中的1个单独字节 您需要设计某种帧协议,让接收者知道他们何时拥有整个消息。 这可能像长度前缀一样简单,也可能更复杂。 然后,您应该将数据缓冲在内存中(或逐步处理),直到您拥有整个消息。 对Read一次调用不太可能代表单个完整的消息。 实际上,如果消息大于newstate.buffer ,则保 ...
  • 确定发现了问题,你必须在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 :) sock ...

相关文章

更多

最新问答

更多
  • 如何在Laravel 5.2中使用paginate与关系?(How to use paginate with relationships in Laravel 5.2?)
  • linux的常用命令干什么用的
  • 由于有四个新控制器,Auth刀片是否有任何变化?(Are there any changes in Auth blades due to four new controllers?)
  • 如何交换返回集中的行?(How to swap rows in a return set?)
  • 在ios 7中的UITableView部分周围绘制边界线(draw borderline around UITableView section in ios 7)
  • 使用Boost.Spirit Qi和Lex时的空白队长(Whitespace skipper when using Boost.Spirit Qi and Lex)
  • Java中的不可变类(Immutable class in Java)
  • WordPress发布查询(WordPress post query)
  • 如何在关系数据库中存储与IPv6兼容的地址(How to store IPv6-compatible address in a relational database)
  • 是否可以检查对象值的条件并返回密钥?(Is it possible to check the condition of a value of an object and JUST return the key?)
  • GEP分段错误LLVM C ++ API(GEP segmentation fault LLVM C++ API)
  • 绑定属性设置器未被调用(Bound Property Setter not getting Called)
  • linux ubuntu14.04版没有那个文件或目录
  • 如何使用JSF EL表达式在param中迭代变量(How to iterate over variable in param using JSF EL expression)
  • 是否有可能在WPF中的一个单独的进程中隔离一些控件?(Is it possible to isolate some controls in a separate process in WPF?)
  • 使用Python 2.7的MSI安装的默认安装目录是什么?(What is the default installation directory with an MSI install of Python 2.7?)
  • 寻求多次出现的表达式(Seeking for more than one occurrence of an expression)
  • ckeditor config.protectedSource不适用于editor.insertHtml上的html元素属性(ckeditor config.protectedSource dont work for html element attributes on editor.insertHtml)
  • linux只知道文件名,不知道在哪个目录,怎么找到文件所在目录
  • Actionscript:检查字符串是否包含域或子域(Actionscript: check if string contains domain or subdomain)
  • 将CouchDB与AJAX一起使用是否安全?(Is it safe to use CouchDB with AJAX?)
  • 懒惰地初始化AutoMapper(Lazily initializing AutoMapper)
  • 使用hasclass为多个div与一个按钮问题(using hasclass for multiple divs with one button Problems)
  • Windows Phone 7:检查资源是否存在(Windows Phone 7: Check If Resource Exists)
  • 无法在新线程中从FREContext调用getActivity()?(Can't call getActivity() from FREContext in a new thread?)
  • 在Alpine上升级到postgres96(/ usr / bin / pg_dump:没有这样的文件或目录)(Upgrade to postgres96 on Alpine (/usr/bin/pg_dump: No such file or directory))
  • 如何按部门显示报告(How to display a report by Department wise)
  • Facebook墙贴在需要访问令牌密钥后无法正常工作(Facebook wall post not working after access token key required)
  • Javascript - 如何在不擦除输入的情况下更改标签的innerText(Javascript - how to change innerText of label while not wiping out the input)
  • WooCommerce / WordPress - 不显示具有特定标题的产品(WooCommerce/WordPress - Products with specific titles are not displayed)