我正在尝试创建一个tcp同步服务器.我的主线程将创建侦听端口,并且传入的连接将由线程处理.
我的代码:
void WorkerThread(boost::shared_ptr< boost::asio::io_service > io_service)
{
io_service->run();
}
void Application::server()
{
boost::shared_ptr< boost::asio::io_service > io(
new boost::asio::io_service()
);
boost::shared_ptr< boost::asio::io_service::work > work(
new boost::asio::io_service::work(*io)
);
// Open the acceptor with the option to reuse the address (i.e. SO_REUSEADDR
boost::asio::ip::tcp::acceptor acceptor(*io);
boost::asio::ip::tcp::endpoint endpoint(boost::asio::ip::tcp::v4(), 2198);
acceptor.open(endpoint.protocol());
acceptor.set_option(boost::asio::ip::tcp::acceptor::reuse_address(true));
acceptor.bind(endpoint);
acceptor.listen();
// pool of threads
boost::thread_group worker_threads;
for(int x = 0; x < 5; ++x)
{
worker_threads.create_thread(boost::bind(&WorkerThread, io));
}
while(true)
{
boost::shared_ptr< boost::asio::ip::tcp::socket > socket(
new boost::asio::ip::tcp::socket( *io )
);
acceptor.accept(*socket);
processConnection(*socket); …Run Code Online (Sandbox Code Playgroud) 我可以使用以下cURL命令将HTTP POST文本文件发送到我的服务器:
curl -i -F file=@file.txt http://www.website.com/put_file
Run Code Online (Sandbox Code Playgroud)
服务器期待来自$ _FILES ['file']的文件.
到目前为止,我有以下内容,但它不起作用:
$url = http://www.website.com/put_file
$file = "c:\file.txt"
$wc = new-object System.Net.WebClient
$wc.UploadFile($url, $file.FullName)
Run Code Online (Sandbox Code Playgroud)
它返回0,并且没有上传到服务器
如何将文件作为$ _FILES ['file']发送?另外,如何从服务器看到响应?
我有两组LinkedHashSet对象,在这个对象中我有其他对象有更多LinkedHashSet.
我的问题是:
该equals方法(默认)是否检查所有内部HashSets是否相同?或者我必须覆盖它?
我正在尝试使用以下代码执行 .bat 以在我的本地主机(服务器端)上启动 notepad.exe:
索引.asp
<%
set wshell = CreateObject("WScript.Shell")
return = wshell.run("c:\file.bat", 4, false)
response.write(return)
set wshell = nothing
%>
Run Code Online (Sandbox Code Playgroud)
文件.bat
notepad.exe
Run Code Online (Sandbox Code Playgroud)
当我打开 ASP 页面时,没有任何反应。由于变量“return”,返回值 0。所以我尝试将false值设置为true,然后服务器冻结并且没有返回任何内容;我认为这是因为没有从 .bat 文件返回值。我还尝试直接运行 notepad.exe ( C:\Windows\notepad.exe ) 而不是使用 .bat 文件,但仍然没有任何反应。我也尝试使用 ASPExec.dll 但也无济于事。
有谁知道我做错了什么?
更多信息:
我的本地 Web 服务器是 Windows 7 附带的 IIS7。我在 localhost 上这样做只是为了测试目的。我必须在 Classic ASP 中完成此操作,因为最终我必须将网站导入 WinCE7 设备。我知道 WshShell 不适用于 WinCE,但现在我只是想看看它是否有效。最终,我将需要能够运行 .exe,通过网站在设备上安装更新。
我有以下代码:
private static class Node {
public LinkedHashSet<String> s = new LinkedHashSet<String>();
public Node(String s) {
this.s.add(s);
}
}
public static void main(String[] args) {
LinkedHashSet<Node> set1 = new LinkedHashSet<Node>();
set1.add(new Node("foo"));
LinkedHashSet<Node> set2 = new LinkedHashSet<Node>(set1);
LinkedHashSet<String> modifyingSet = new LinkedHashSet<String>();
modifyingSet.add("modifying foo");
for(Node n : set2) {
n.s = new LinkedHashSet<String>(modifyingSet);
break;
}
if (compare(set1, set2)) {
System.out.println("Equal");
} else {
System.out.println("Not Equal");
}
return;
}
private static boolean compare(LinkedHashSet<Node> h1, LinkedHashSet<Node> h2) {
Iterator<Node> h1i = h1.iterator(); …Run Code Online (Sandbox Code Playgroud) java ×2
asp-classic ×1
boost ×1
boost-asio ×1
c++ ×1
curl ×1
hashset ×1
http-post ×1
localhost ×1
post ×1
powershell ×1
server-side ×1
windows ×1
wsh ×1