如何制作一个简单的Websocket Html(客户端)和简单的可视化c ++服务器 [英] How to make a Websocket simple Html (client) and simple visual c++ Server
本文介绍了如何制作一个简单的Websocket Html(客户端)和简单的可视化c ++服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有Html客户端。我需要向visual c ++服务器发送一条消息
I have Html Client. and i need send one message to visual c++ server
<!DOCTYPE HTML>
<html>
<head>
<script type="text/javascript">
function WebSocketTest()
{
if ("WebSocket" in window)
{
alert("WebSocket is supported by your Browser!");
// Let us open a web socket
var ws = new WebSocket("ws://localhost:1112/");
ws.onopen = function()
{
// Web Socket is connected, send data using send()
ws.send("Message to send");
alert("Message is sent...");
};
ws.onmessage = function (evt)
{
var received_msg = evt.data;
alert("Message is received...");
};
ws.onclose = function()
{
// websocket is closed.
alert("Connection is closed...");
};
}
else
{
// The browser doesn't support WebSocket
alert("WebSocket NOT supported by your Browser!");
}
}
</script>
</head>
<body>
<div id="sse">
<a href="javascript:WebSocketTest()">Run WebSocket</a>
</div>
</body>
</html>
如何在一个简单的(服务器可视化c ++) * .cpp,可以帮助我吗?
How to make this (server visual c++) in one simple *.cpp, can help me?
推荐答案
在Windows中使用WinSocket-API: http://msdn.microsoft.com/de-de/library/windows/desktop/ms741394(v = vs.85)的.aspx [ ^ ]
a好样本项目:开始Winsock编程 - 简单的TCP服务器 [ ^ ]
use the WinSocket-API in Windows: http://msdn.microsoft.com/de-de/library/windows/desktop/ms741394(v=vs.85).aspx[^]
a good sample project: Beginning Winsock Programming - Simple TCP server[^]
这篇关于如何制作一个简单的Websocket Html(客户端)和简单的可视化c ++服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文