那个朋友将近毕业 需要这条程序 但他是学机械的 不懂vb 希望有朋友能帮忙完成只要编译能通过就可以了..能实现服务端接收数据.不要求客户端-----------------------------------------------------------------------数据接收程序
Option Explicit
Private Const winsk_local_port = 8888
Private Const max_sessions = 10
Private Sub Form_Load()
Dim i As Integer
With Winsk(0)
.Protocol = sckTCPProtocol
.LocalPort = winsk_local_port
.Listen
End With
For i = 1 To max_sessions
Load Winsk(i)
Winsk(i).Protocol = sckTCPProtocol
Winsk(i).LocalPort = winsk_local_port
Next
End SubPrivate Sub Winsk_ConnectionRequest(Index As Integer, ByVal requestID As Long)
Dim str As String
Dim i As Integer
MsgBox "aaa"
If Index = 0 Then
For i = 0 To max_sessions
With Winsk(i)
If .State = sckClosed Then
Accept requestID
Exit For
End If
End With
Next
End If
End SubPrivate Sub Winsk_DataArrival(Index As Integer, ByVal bytesTotal As Long)
Dim str As String
Dim rc As Integer
Dim i As Integer
MsgBox "收到!"
Winsk(Index).GetData str, , bytesTotal
messages.AddItem str
For i = 1 To max_sessions
With Winsk(i)
If .State = sckConnected Then
SendData str
DoEvents
End If
End With
Next
End Sub---------------------------------------
谢谢^_^

解决方案 »

  1.   

    你可以用UDP来实现即可~~
      

  2.   

    I don't install vb in my machine. can you give error msg here?
      

  3.   

    chenhui530 朋友 我也不懂vb  -_-!!
      

  4.   

    If .State = sckClosed Then
    Accept requestID              '改成  .Accept requestID 
    Exit For
    End If
    If .State = sckConnected Then
    SendData str             '这里是干什么的?广播消息么?如果是,改成  .SendData str
    DoEvents
    End If