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

Reading Data from a specific port

i want to read data which is broadcast on port like 4010,4011,4012

guide me with code example
0
pak_slm
Asked:
pak_slm
1 Solution
 
robknowlesCommented:
I think you'd have to create an application which uses a winsock application to listen on those ports, then accept the connection (and if there will me multiple messages broadcast at the same time, you need to use control arrays so that you can accept multiple connection simultaniously), then read through the data as it is received etc.  Unfortunately I dont have the time at the moment to build you an example sorry.

Cheers
0
 
dr_binksCommented:
I can give you example code.. I just need to know if you want to make a server or a client.
0
 
pak_slmAuthor Commented:
dr_binks

i could not understand  server or client option. The environment is like we have two department. Other department have a programm name Gateway which broadcast some info like rate, symbol, type etc on a port. we run this programm on one computer. Now i want to read that info to use in the programm.
0
 
Jaime OlivaresSoftware ArchitectCommented:
>i want to read data which is broadcast on port like 4010,4011,4012
I think you need a client application to receive UDP broadcasts.

insert a WinSock control into your main form and  name it listen4010, something like this:

Private Sub Form_Load()
    With listen4010
        .RemoteHost= "PeerB"   ' Name of the remote host
        .RemotePort = 4010  ' Port to connect to.
        .Bind 1001                ' Bind to the local port.
    End With
End Sub

Then you have to implement the reception function, something like

Private Sub listen4010_DataArrival (ByVal bytesTotal As Long)
    Dim data As String
    Dim msg As String
    listen4010.GetData data
    ' now data contains the frame received, but I guess data will be binary, so convert it to a 'readable' string
    For I = 0 to len(data)
         msg = msg & hex(asc(mid(data,I,1)))
    Next I
    MsgBox msg
End Sub

You will have to introduce more controls to listen more ports.

Some extra information at:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon98/html/vbconusingwinsockcontrol.asp
0
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.

Join & Write a Comment

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone 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