我已经建立了一个TCP/IP服务器/客户端,它是异步的,但它连接了消息.我如何正确地在开始时添加标题,然后在最后使用字符串构建器来取消连接完整的消息.
服务器读取消息:
Private Sub ReadCallback(ByVal result As IAsyncResult)
Try
allDone.Set()
Dim success As Boolean = result.AsyncWaitHandle.WaitOne(500, True)
If success Then
Dim client As ServerClient = TryCast(result.AsyncState, ServerClient)
If client Is Nothing Then
Return
End If
Dim networkStream As NetworkStream = client.NetworkStream
Dim read As Integer = networkStream.EndRead(result)
If read = 0 Then
SyncLock Me.Clients
Me.Clients.Remove(client.ClientID)
Return
End SyncLock
End If
If client.NetworkStream.CanRead Then
dataString.Append(Me.Encoding.GetString(client.buffer, 0, read))
networkStream.BeginRead(client.buffer, 0, client.buffer.Length, AddressOf ReadCallback, client)
allDone.WaitOne(500, True)
End If
End If
Catch ex …Run Code Online (Sandbox Code Playgroud) <table id="myTable0" name="myTable0">
<tbody>
<tr>
</tr>
</tbody>
</table>
<table id="myTable1" name="myTable1">
<tbody>
<tr>
</tr>
</tbody>
</table>
Run Code Online (Sandbox Code Playgroud)
我需要一些JQuery,它会尝试将新的html附加到表的末尾并在输入键上执行,它还会选择正确的表来附加它,因为有很多表.
这是我的代码不起作用但尝试这样做:
for (i=0; i<2; i++)
{
$("#newComment" + i).keyup(function(event){
if(event.keyCode == 13){
var $test= $('<tr><td>content here</td></tr>');
$('#myTable '+ i + ' > tbody:last').append($test);
}
}
Run Code Online (Sandbox Code Playgroud)
抛出我问题的那一行是Jquery选择如下:
$('#myTable '+ i + ' > tbody:last').append($newdiv1);
Run Code Online (Sandbox Code Playgroud)