| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 320 人关注过本帖
标题:网络传输问题
只看楼主 加入收藏
公里21
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2011-8-14
结帖率:100%
收藏
 问题点数:0 回复次数:0 
网络传输问题
我利用winsock控件编写了一个基于TCP协议的软件,只用来传递字符串。在XP下的局域网中测试没有问题,在Windows Server 2008服务器上确总是连不上。程序片段如下:
Private Sub Winsock1_Close()

    Winsock1.Close
    Winsock1.Listen
    Label1.Caption = "监听"
    Label1.ForeColor = RGB(255, 0, 0)
    Text1.Text = Text1.Text + Chr(13) + Chr(10) + Format(Date, "long date") & " " & Time & " " & "连接断开并进入监听状态"     
End Sub

Private Sub Winsock1_ConnectionRequest(ByVal requestID As Long)

    If Winsock1.State <> sckClosed Then
        Winsock1.Close
        Text1.Text = Text1.Text + Chr(13) + Chr(10) + Format(Date, "long date") & " " & Time & " " & "发出连接请求,端口暂时关闭"
        Winsock1.Accept requestID
        Text1.Text = Text1.Text + Chr(13) + Chr(10) + Format(Date, "long date") & " " & Time & " " & "接受发出的连接请求"        
        If Winsock1.State = sckConnected Then
            Label1.Caption = "连接"
            Label1.ForeColor = RGB(0, 128, 0)
            Text1.Text = Text1.Text + Chr(13) + Chr(10) + Format(Date, "long date") & " " & Time & " " & "建立了新的连接"
            Winsock1.SendData "接受"
        End If
    End If
End Sub

Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
   
    Dim myStr As String
    Winsock1.GetData myStr
    Text1.Text = Text1.Text + Chr(13) + Chr(10) + Format(Date, "long date") & " " & Time & " " & "接收到数据"
    Text18.Text = myStr
    If Winsock2.State = sckConnected Then
        Winsock2.SendData myStr
        Text1.Text = Text1.Text + Chr(13) + Chr(10) + Format(Date, "long date") & " " & Time & " " & "将数据转发"
    End If
   
End Sub

请高手们解答,谢谢!
搜索更多相关主题的帖子: 服务器 Windows 局域网 字符串 
2012-12-14 22:31
快速回复:网络传输问题
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.025274 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved