2013-11-01 32 views
0

当前在Excel 2007中使用wsock.dll连接到TCP服务器。我可以派出一些东西,这很好。然而,关于接收,有没有什么办法让事件驱动,因为我不知道什么时候有一个味精发送到Excel?直到有东西抵达,recv电话将被阻止。在Excel中的winsock异步接收

回答

1

如果您可以亲自使用Winsock ActiveX控件,然后you can used an event-based programming model。我摘录这个例子访问:

Private Sub axWinsockServer_DataArrival(ByVal bytesTotal As Long) 
    Dim strClientMsg As String 

    ' The DataArrival event fires on the server when the client sends 
    ' information. Get the data and display it in a text box. 
    wsServer.GetData strClientMsg, vbString 
    Me!Text1.Value = strClientMsg 
End Sub 

虽然考虑为什么,就是这样,你需要一个电子表格做网络通信。

+0

我可以知道winsock activex是免费下载吗? –

+0

据我所知,它是免费的,但非常老旧。它是第一方(即微软)。 –

+0

好的谢谢。顺便说一句,你知道如果有一个非自由的winsock activex控件吗?我找到一个叫做alt winsock activex的。但是,它只能发送ascii而不是二进制数据 –