Alpha Software Mobile Development Tools:   Alpha Anywhere    |   Alpha TransForm subscribe to our YouTube Channel  Follow Us on LinkedIn  Follow Us on Twitter  Follow Us on Facebook

Announcement

Collapse

The Alpha Software Forum Participation Guidelines

The Alpha Software Forum is a free forum created for Alpha Software Developer Community to ask for help, exchange ideas, and share solutions. Alpha Software strives to create an environment where all members of the community can feel safe to participate. In order to ensure the Alpha Software Forum is a place where all feel welcome, forum participants are expected to behave as follows:
  • Be professional in your conduct
  • Be kind to others
  • Be constructive when giving feedback
  • Be open to new ideas and suggestions
  • Stay on topic


Be sure all comments and threads you post are respectful. Posts that contain any of the following content will be considered a violation of your agreement as a member of the Alpha Software Forum Community and will be moderated:
  • Spam.
  • Vulgar language.
  • Quotes from private conversations without permission, including pricing and other sales related discussions.
  • Personal attacks, insults, or subtle put-downs.
  • Harassment, bullying, threatening, mocking, shaming, or deriding anyone.
  • Sexist, racist, homophobic, transphobic, ableist, or otherwise discriminatory jokes and language.
  • Sexually explicit or violent material, links, or language.
  • Pirated, hacked, or copyright-infringing material.
  • Encouraging of others to engage in the above behaviors.


If a thread or post is found to contain any of the content outlined above, a moderator may choose to take one of the following actions:
  • Remove the Post or Thread - the content is removed from the forum.
  • Place the User in Moderation - all posts and new threads must be approved by a moderator before they are posted.
  • Temporarily Ban the User - user is banned from forum for a period of time.
  • Permanently Ban the User - user is permanently banned from the forum.


Moderators may also rename posts and threads if they are too generic or do not property reflect the content.

Moderators may move threads if they have been posted in the incorrect forum.

Threads/Posts questioning specific moderator decisions or actions (such as "why was a user banned?") are not allowed and will be removed.

The owners of Alpha Software Corporation (Forum Owner) reserve the right to remove, edit, move, or close any thread for any reason; or ban any forum member without notice, reason, or explanation.

Community members are encouraged to click the "Report Post" icon in the lower left of a given post if they feel the post is in violation of the rules. This will alert the Moderators to take a look.

Alpha Software Corporation may amend the guidelines from time to time and may also vary the procedures it sets out where appropriate in a particular case. Your agreement to comply with the guidelines will be deemed agreement to any changes to it.



Bonus TIPS for Successful Posting

Try a Search First
It is highly recommended that a Search be done on your topic before posting, as many questions have been answered in prior posts. As with any search engine, the shorter the search term, the more "hits" will be returned, but the more specific the search term is, the greater the relevance of those "hits". Searching for "table" might well return every message on the board while "tablesum" would greatly restrict the number of messages returned.

When you do post
First, make sure you are posting your question in the correct forum. For example, if you post an issue regarding Desktop applications on the Mobile & Browser Applications board , not only will your question not be seen by the appropriate audience, it may also be removed or relocated.

The more detail you provide about your problem or question, the more likely someone is to understand your request and be able to help. A sample database with a minimum of records (and its support files, zipped together) will make it much easier to diagnose issues with your application. Screen shots of error messages are especially helpful.

When explaining how to reproduce your problem, please be as detailed as possible. Describe every step, click-by-click and keypress-by-keypress. Otherwise when others try to duplicate your problem, they may do something slightly different and end up with different results.

A note about attachments
You may only attach one file to each message. Attachment file size is limited to 2MB. If you need to include several files, you may do so by zipping them into a single archive.

If you forgot to attach your files to your post, please do NOT create a new thread. Instead, reply to your original message and attach the file there.

When attaching screen shots, it is best to attach an image file (.BMP, .JPG, .GIF, .PNG, etc.) or a zip file of several images, as opposed to a Word document containing the screen shots. Because Word documents are prone to viruses, many message board users will not open your Word file, therefore limiting their ability to help you.

Similarly, if you are uploading a zipped archive, you should simply create a .ZIP file and not a self-extracting .EXE as many users will not run your EXE file.
See more
See less

Reading/writing raw Tcp/ip

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Reading/writing raw Tcp/ip

    Is there a way to send a raw tcp/ip packet like from a text file. I can telnet connection from a commandline telnet program, but don't know how to get the response. I connect to a telnet connection then i have to send
    Action: login
    Username: whatever
    Secret: 1234

    then i send

    Action: ExtensionState
    ActionId: 1
    Exten: 2503

    Using the <crlf> between commands then <crlf><crlf> to get the response, it comes on screen like this

    Response: Success
    ActionID: 1
    Message: Extension Status
    Exten: 2503
    Context: default
    Hint: SIP/2503
    Status: 0


    Is there a way alpha can read this into a table???
    https://www.housingeducator.org
    k3srg

  • #2
    Re: Reading/writing raw Tcp/ip

    Screen Scraping
    There can be only one.

    Comment


    • #3
      Re: Reading/writing raw Tcp/ip

      That doesn't even come close it's not a webpage, it a command prompt window i might be able to run a command to save to output to a text file that i know alpha can read. I'll need to research some more.
      https://www.housingeducator.org
      k3srg

      Comment


      • #4
        Re: Reading/writing raw Tcp/ip

        Hi Steve745,

        Once I made an example to run xbasic code which was hidden in MSWord fields and send it to Alpha Five with sockets. Look at this post maybe it may help.
        Marcel

        I hear and I forget. I see and I remember. I do and I understand.
        ---- Confusius ----

        Comment


        • #5
          Re: Reading/writing raw Tcp/ip

          i was reading through help and i think i can make use of
          Code:
          INET::Socket::Connect( Host as C, Port as N [, ConnectTimeout as N ] )
          Just have to figure out how to use it
          https://www.housingeducator.org
          k3srg

          Comment


          • #6
            Re: Reading/writing raw Tcp/ip

            Ok i have been testing in interactive window i think i'm connecting but not sure how to read back from the connection here is the code i trying
            Code:
            dim LocalSocket as INET::Socket
            dim h as C
            dim com as C
            dim BYREF as C
            h="pbx.local"
            com= "Action: login<CRLF>Username:steven<CRLF>Secret: nov212001<CRLF>ACTION: ExtensionState<CRLF>Exten: 2504<CRLF>ActionID: 1<CRLF>Response:"
            LocalSocket.Connect(h,5083)
            LocalSocket.Write(com)
            LocalSocket.Read(BYREF)
            ?BYREF
            https://www.housingeducator.org
            k3srg

            Comment


            • #7
              Re: Reading/writing raw Tcp/ip

              I have done some reading around and i am making the connection but can't figure out how to pass the commands to move on.
              Code:
              dim bs as p = sockets.open("192.168.1.2.",5038,"C")
              dim bsOutput as c
              dim login as C
              dim Action as C
              dim action as C
              log = "Action: login<CRLF>Username: steven<CRLF>Secret: nov212001<CRLF><CRLF>"
              action = "Action: ExtensionState<CRLF>Exten: 2503<CRLF>ActionId: 1<CRLF><CRLF>"
              bs.write(log)  
              bs.write(action)
              bsOutput = bs.readb()
              trace.writeln(bsOutput)
              all i get in the trace is the first login screen, nothing further. i have to pass login info by using Action: login<CRLF>
              Username: steven<CRLF>

              in that manner can anyone see what i'm doing that isn't right
              https://www.housingeducator.org
              k3srg

              Comment


              • #8
                Re: Reading/writing raw Tcp/ip

                Hi Steve745,

                Did you create a listener (server) who listens to your socket.write and act upon?
                Marcel

                I hear and I forget. I see and I remember. I do and I understand.
                ---- Confusius ----

                Comment


                • #9
                  Re: Reading/writing raw Tcp/ip

                  There is a server already running. a different program. i get comformation that it connects but can't figure out how to pass the commands
                  https://www.housingeducator.org
                  k3srg

                  Comment


                  • #10
                    Re: Reading/writing raw Tcp/ip

                    Steve, I do not know <crlf>, replace it by the Xbasic crlf() function.

                    Code:
                    log = "Action: login" + crlf() + "Username: steven" + crlf() + "Secret: nov212001" + crlf(2)
                    Change the other lines accordingly the example above.
                    Marcel

                    I hear and I forget. I see and I remember. I do and I understand.
                    ---- Confusius ----

                    Comment


                    • #11
                      Re: Reading/writing raw Tcp/ip

                      I was scratching my head this morning and started changing it, then i came to an error i think related to the formatting. I'm going to try you insert see what i come up with
                      https://www.housingeducator.org
                      k3srg

                      Comment


                      • #12
                        Re: Reading/writing raw Tcp/ip

                        here is what i got it won't get a response after i send action to start login using var->log.
                        Code:
                        dim bs as p = sockets.open("192.168.1.2.",5038,"C")
                        dim bsOutput as c
                        dim log as C
                        dim action as C
                        dim pass as c
                        pass = "nov212001"
                        log = "Action: login" + crlf() + "Username: steven" + crlf() + "Secret: nov212001" + crlf(2)
                        bs.write(log)
                        'action=sockets.write()
                        bsOutput = sockets.readb()
                        trace.writeln(bsOutput)
                        ?bs
                        = P Accept([C flags[, N Timeout]])  'Accept an open sockets input.  Returns a new accepted socket.  flags - 'B' = blocking .
                        C address_get([C flags])  'Get the ip address of an open socket.  (R = remote IP, L = local IP)
                        C Busy()  'Returns a string if the socket is blocked.
                        C Class()  'Get the class name.
                        V Close()  'Close an open socket.
                        V Datagram_Handler(C Name,N tcp_port,C match,C code)  'Setup an named asynchronous handler - when input matches the 'match string' , the code will be invoked with the incoming string in a_message.
                        V Datagram_Kill(C Name)  'Close down a datagram handler.
                        V Datagram_Send(C Host,N port,C data)  'Send data to a host/port.
                        C Datagram_Send_With_Receipt(C Host,N port,C data[,C return_pattern])  'Send data to a host/port wait for returned response.
                        ftp_get_reply as c(timeout as n,vars as p)  'Get an ftp reply - returns the text '<CONNECTIONRESET>' if connection was reset.
                        ftp_put_file as n(filename as c,remotefilename as c,vars as p)  'Put an ftp file up - returns the result code.
                        V handle_get(C options)  'Get a sockets logical slot - used with the 'sockets.wait' function.
                        N Handle_Id()  'Get the integer handle id for the socket variable.
                        C Info_Get([C ip_info_format[,C address]])  'Get information for an address.
                        L IsOpen()  'Check to see if a socket has been opened successfully.  Does not guarantee that subsequent calls will succeed!
                        P Open(C Host,N tcp_port[,C mode, [N ConnectTimeout]])  'Open an existing socket - mode is S for server, C for client, L for Listen (server without accept), R for server with reuse address flag.
                        V options_get(C options)  'Get options (A-accepting L-Linger K-Keep Alive R-Reuse Address N-Don't route D-elay X-Debug - I=input buffer O=output buffer T=timeout -  '' escapes characters ).
                        V options_set(C options)  'Set options ([-]L-Linger K-Keep Alive R-Reuse Address N-Don't route [-]D-elay X-Debug  - I=#/O=# - internal input output buffer controls T=# TS=# TR=# timout in milliseconds for timeout on send/receive or timeout [S]end,[R]ecieve ).
                        C Peek(N Length)  'Read bytes from socket into string without removing the bytes from the socket stream.
                        N port_get(C flags)  'Get the port for an open socket.  (R = remote port, L = local port)
                        L query_tcp(C local_host, N local_port, C remote_host, N remote_port, N state)  'Return if the TCP port is in use.
                        C Read([N Length [, N Timeout ]])  'Read bytes from socket into string.
                        B ReadB([N Length [, N Timeout]])  'Read bytes from socket into blob.
                        C ReadLine()  'Reads a line from the socket, if one is available (else returns blank).
                        V wait(N timeout,C wait_list)  'Wait list is formatted as cr-lf separated list of R[#] W[#] and E[#] for wait on read/write or error for sockets .
                        V Write(C String[,N Length])  'Write string to socket.
                        V WriteB(B Blob)  'Write blob to socket.
                        I do get 1 line in trace that tells me it connected tells me the server name and version.
                        https://www.housingeducator.org
                        k3srg

                        Comment


                        • #13
                          Re: Reading/writing raw Tcp/ip

                          i just did ?bs.read() and got my output from the server, now just have to figure out how to write that to a table and field.
                          https://www.housingeducator.org
                          k3srg

                          Comment


                          • #14
                            Re: Reading/writing raw Tcp/ip

                            I got it connecting and reading/writing here is the code from interactive
                            Code:
                            dim bs as p = sockets.open("192.168.1.2.",5038,"C")
                            dim bsOutput as c
                            dim log as C
                            dim action as C
                            dim response as c
                            log = "Action: login" + crlf() + "Username: steven" + crlf() + "Secret: nov212001" + crlf(2)
                            bs.write(log)
                            response = bs.readb()
                            file.append("c:\livetransfer\test.txt", response)
                            action = "Action: ExtensionState" + crlf() + "Exten: 2503" + crlf() +"ActionId: 1" + crlf(2)
                            bs.write(action)
                            response = bs.readb()
                            file.append("c:\livetransfer\test.txt", response)
                            response = bs.readb()
                            file.append("c:\livetransfer\test.txt", response)
                            
                            ?response
                            = Response: Success
                            ActionID: 1
                            Message: Extension Status
                            Exten: 2503
                            Context: default
                            Hint: SIP/2503
                            Status: 4
                            My next step is to figure out how to count the line of the text file and write to a table and field. or is there a way i can write the last response directly to a table record????
                            https://www.housingeducator.org
                            k3srg

                            Comment


                            • #15
                              Re: Reading/writing raw Tcp/ip

                              Originally posted by steve745 View Post
                              i just did ?bs.read() and got my output from the server, now just have to figure out how to write that to a table and field.
                              Nice job. Don't forget to include proper timeout values for the sockets commands just to overcome the process hangs when something goes wrong. Look also at this post from Graham Wickens. He did a fine job getting information by tcp/ip from a data device.

                              I do not know if the process you are dealing with can consume all the time of your program. If not put the collection process in a background thread.

                              More links: post1, post2
                              Last edited by Marcel Kollenaar; 01-01-2010, 03:33 PM. Reason: Added links to more information.
                              Marcel

                              I hear and I forget. I see and I remember. I do and I understand.
                              ---- Confusius ----

                              Comment

                              Working...
                              X