UDP query (code only)

Posted on 2004-11-12
Last Modified: 2013-11-13
Hi I need UDP code for VB6 that will send the following query string : \xFE\xFD\x00"."AASF"."\xFF\xFF\xFF to a server on port 1717. The recieved data needs to be printed to a file, lets say c:\out.txt.

I want it to be code only, no form, just run the exe and get the txt file with the recieved data.
Question by:mdeschen

    Author Comment

    No one have any idea? It can involve using an external component too (must be froo though).
    LVL 17

    Accepted Solution

    Here's an example using the Winsock control. Pres Ctrl+T and add "Microsoft Winsock Control x.x" and add 2 controls with the names of sckServer and sckClient.

    Private Sub Command1_Click()
        'send data to 1717 (sckServer)
        Dim strData As String
        'not sure about the below string.. ie: if you wanted to include the ".", "AASF" or send the
        'hex as longs or characters
        strData = Chr(&HFE) & Chr(&HFD) & Chr(&H0) & ".AASF." & Chr(&HFF) & Chr(&HFF) & Chr(&HFF)
        sckClient.Protocol = sckUDPProtocol
        sckClient.RemoteHost = ""
        sckClient.RemotePort = 1717
        sckClient.SendData strData
    End Sub
    Private Sub Form_Load()
        'bind server (udp) to port 1717
        sckServer.Protocol = sckUDPProtocol
        sckServer.LocalPort = 1717
    End Sub
    Private Sub sckServer_DataArrival(ByVal bytesTotal As Long)
        Dim strData As String
        'get data
        sckServer.GetData strData
        'print to "c:\test.txt"
        Open "c:\test.txt" For Output As 1
            Print #1, strData
        Close 1
    End Sub

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
    I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
    This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
    This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

    794 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now