请教各位,我会用winsock的tcp方式编写一些小的程序,我想知道如何用udp编写,请问各位有没有什么好的源代码给我学习学习吗?多谢了:)

解决方案 »

  1.   

    Option ExplicitPrivate Sub Command1_Click()
        Winsock1.Protocol = sckUDPProtocol
        Winsock1.RemoteHost = Text1.Text
        Winsock1.LocalPort = CLng(Text2.Text)
        Winsock1.RemotePort = CLng(Text3.Text)
        Winsock1.Bind
        Command1.Enabled = False
        Command2.Enabled = True
    End SubPrivate Sub Command2_Click()
        Winsock1.SendData "From A: " & Text4.Text
        Text4.Text = ""
    End SubPrivate Sub Form_Load()
        Label1.Caption = "远程IP"
        Label2.Caption = "远程连接端口"
        Label3.Caption = "近程连接端口"
        Label4.Caption = "信息"
        Command1.Caption = "连接"
        Command2.Caption = "送出信息"
        Command2.Enabled = False
        Text1.Text = "127.1"
        Text2.Text = "6666"
        Text3.Text = "7777"
        Text4.Text = ""
        Text5.Text = ""End SubPrivate Sub Winsock1_DataArrival(ByVal BytesTotal As Long)
        On Error GoTo Errors:    Dim sVar As String
        Winsock1.GetData sVar, vbString
        Text5.Text = sVar & vbCrLf & Text5.Text
        Exit SubErrors:End Sub
      

  2.   

    Option ExplicitPrivate Sub Command1_Click()
        Winsock1.Protocol = sckUDPProtocol
        Winsock1.RemoteHost = Text1.Text
        Winsock1.LocalPort = CLng(Text2.Text)
        Winsock1.RemotePort = CLng(Text3.Text)
        Winsock1.Bind
        Command1.Enabled = False
        Command2.Enabled = True
    End SubPrivate Sub Command2_Click()
        Winsock1.SendData "From B: " & Text4.Text
        Text4.Text = ""
    End SubPrivate Sub Form_Load()
        Label1.Caption = "远程IP"
        Label2.Caption = "远程连接端口"
        Label3.Caption = "近程连接端口"
        Label4.Caption = "信息"
        Command1.Caption = "连接"
        Command2.Caption = "送出信息"
        Command2.Enabled = False
        Text1.Text = "127.1"
        Text2.Text = "7777"
        Text3.Text = "6666"
        Text4.Text = ""
        Text5.Text = ""End SubPrivate Sub Winsock1_DataArrival(ByVal BytesTotal As Long)
        Dim sVar As String
        Winsock1.GetData sVar, vbString
        Text5.Text = sVar & vbCrLf & Text5.Text
    End Sub
      

  3.   

    再问各位高手!网上都有验证代理的软件,但是基本上都是验证http的代理的,请问有没有验证sock代理的源程序呢?这个验证sock代理的程序是不是基于winsock下的udp编写的呢?
      

  4.   

    参考
    http://community.csdn.net/Expert/topic/2723/2723148.xml?temp=.6528589