為啥 Server 都 收不到Client的連線清求呢!? ><
另外~~ 不知道下面我這樣寫的對不對~~~
拜託各位大大救救我ㄚ!!  @@~~
Private Sub Form_Load()
frm_Log.Show '先將frm_Log開啟
  BindTF = False
  SendLog "WSA 作者:小天天"
  '以自己的電腦名稱取得IP
  txtServerIP.Text = SocketAPI.ResolveIP(MyComName.ClassGetComputerName)
  SendLog "本機 IP: " & txtServerIP.Text & " Port: " & txtServerPort.Text
  '先取得Socket的識別碼 for Server
  SErectSocket = SocketAPI.ErectSocket
  If SErectSocket = -1 Then '失敗
    HandError "取得Socket識別碼失敗..."
  Else
  SendLog "Socket識別碼: " & SErectSocket
  TimeAccept.Enabled = True
  '設定目前狀態,預設值是[Server]
  Call Server
  SendLog "定位本程式目前狀態 [ Server ]"
  End If
  Me.Show
End Sub
Public Sub Server()
'Server的基本動作 listening
  'SocketAPI.ErectSocket
  ' SocketAPI.SocketStartup
   Dim Tem As Long
   If SErectSocket = 0 Then SErectSocket = SocketAPI.ErectSocket
   If BindTF = False Then Call BindIPPort
   txtServerIP.Text = SocketAPI.ResolveIP(MyComName.ClassGetComputerName)
'bind MyIP , 服務(Service) , Port
Tem = SocketAPI.SListen(1)
   If Tem <> 0 Then
    HandError "Listen"
   End If
   SendLog "listen 本機 IP: " & txtServerIP.Text & " Port: " & txtServerPort.Text & " 成功"
   SendLog "目前處於監聽狀態中...(等候接受連結)"
End Sub
Public Sub Client() '
If CErectSocket = 0 Then CErectSocket = SocketAPI.ErectSocket
  SendLog "現在連接遠端電腦: [" & txtServerIP & ":" & txtServerPort & "]"
  If BindTF = False Then Call BindIPPort
  '與對方連結
  If SocketAPI.SConnect(txtServerIP, txtServerPort) = 0 Then
    SendLog "與 [" & txtServerIP & "],協調中...."
    SendMess "與 [" & txtServerIP & "],協調中"
    Timer1.Enabled = False
    ClientConnect.Caption = "連接"
  End If
End Sub
arrow
arrow
    全站熱搜

    vbqa 發表在 痞客邦 留言(0) 人氣()