返回首页

请给我一个,我怎么能连接这些简单的例子:

- TCP侦听服务器localhost上的端口33333

- 一个Javascript客户端浏览器上工作

我搜索的JS插座,所有环节的WebSockets或socket.io。他们是非常有益的,如果服务器具有相同的框架创建。

可以请你帮忙吗? {S0的}

编辑:
客户端:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>Untitled Document</title>

</head>

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>

<script src="http://cdn.socket.io/stable/socket.io.js"></script>

 

<script type="text/javascript">

// Create SocketIO instance, connect

var socket = new io.Socket('localhost',{

	port: 33333

});

socket.connect(); 

 

// Add a connect listener

socket.on('connect',function() {

	console.log('Client has connected to the server!');

});

// Add a connect listener

socket.on('message',function(data) {

	console.log('Received a message from the server!',data);

});

// Add a disconnect listener

socket.on('disconnect',function() {

	console.log('The client has disconnected!');

});

 

// Sends a message to the server via sockets

function sendMessageToServer(message) {

	socket.send(message);

}

 

</script>

 

<body> 

 

</body> 

</html>

这在JS的客户端代码甚至没有连接到服务器。

提及:C#客户端与服务器的工作。

回答

评论会员:理查德MacCutchan 时间:2012/02/07
谷歌"TCP服务器的C#",你会发现,你可以实现一些简单的样品
评论会员:曼弗雷德・R.Bihy 时间:2012/02/07
我觉得你只是没有看到,因为你的连接连接调用之前,你有你的插座上设置的听众。所以,如果你移动连接电话监听器已经设置后会发生什么呢?

或者你可以尝试监视的服务器程序,观察客户端活动的任何痕迹。{BR​​}
的问候,

曼弗雷德