Reading Data from a specific port

Posted on 2005-04-08
Last Modified: 2013-11-13
i want to read data which is broadcast on port like 4010,4011,4012

guide me with code example
Question by:pak_slm
    LVL 1

    Expert Comment

    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.

    LVL 5

    Expert Comment

    I can give you example code.. I just need to know if you want to make a server or a client.
    LVL 1

    Author Comment


    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.
    LVL 55

    Accepted Solution

    >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:

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
    This article will show, step by step, how to integrate R code into a R Sweave document
    The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
    Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

    779 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

    14 Experts available now in Live!

    Get 1:1 Help Now