• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 195
  • Last Modified:

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.
0
mdeschen
Asked:
mdeschen
1 Solution
 
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

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now