UDP query (code only)

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.
mdeschenAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

mdeschenAuthor Commented:
No one have any idea? It can involve using an external component too (must be froo though).
0
zzzzzoocCommented:
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 = "127.0.0.1"
    sckClient.RemotePort = 1717
    sckClient.SendData strData
    '\xFE\xFD\x00"."AASF"."\xFF\xFF\xFF
End Sub
Private Sub Form_Load()
    'bind server (udp) to port 1717
    sckServer.Protocol = sckUDPProtocol
    sckServer.LocalPort = 1717
    sckServer.Bind
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
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Programming Languages-Other

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.