Page 1 of 2 12 LastLast
Results 1 to 10 of 19

Thread: Connecting to an Established Server

  1. #1

    Connecting to an Established Server

    Hi Folks,

    I need a little help.

    I wish to connect to a database server. The database is powerful but character based.

    Once I successfully establish a connection (TCP/IP is normally used), I understand I will be able to communicate effectively using the udp_send and udp_receive functions to send and receive text strings.

    I'm having trouble establishing the initial connection. My attempts have been based on my (demonstrably inadequate) understanding of the UDP_Notify_Client.tbasic program.

    I need to establish a TCP connection (with "localhost" 127.0.0.1 initially, for testing purposes), on server port 2300.

    Once connection is established, I will send a carriage return to elicit a "Login:" request. Replying to that will trigger a "Password:" request, to which I will reply in turn. After that, I should be able to happily pass text strings backwards and forwards between my thinBasic program and a control program on the server.

    Can anyone give me a few clues re establishing the initial connection, please?

    Thanks,

    Peter H.



    Thought for the day (in a broad Australian accent):<br />First of all yer gungadin. Afterwards yer gungadout.

  2. #2

    Re: Connecting to an Established Server

    Hi Peter,

    Until you get a thinBASIC solution worked out, this should do it for you.

    C:> sendit mycmds.txt

    If it works, try redirecting commands from the console or redirecting output to a file.

    FileName = COMMAND()
    OPEN FileName FOR INPUT AS #1
    OPEN "127.0.0.1:2300" FOR SOCKET AS #2
    REPEAT
    LINE INPUT #1, FileCmd
    PRINT #2, FileCmd
    LINE INPUT #2,Response
    PRINT Response
    UNTIL EOF(1)
    
    Note: Untested Program.
    I attached a zip that has sendit.exe
    Attached Files Attached Files
    ScriptBasic Project Manager
    Project Site
    support@scriptbasic.org

  3. #3
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    7,128
    Rep Power
    732

    Re: Connecting to an Established Server

    Hi Peter,

    and welcome to ThinBASIC forums!

    Could you please post code you use currently for connecting to database?


    Petr
    Learn 3D graphics with ThinBASIC, learn TBGL!
    Windows 10 64bit - Intel Core i5-3350P @ 3.1GHz - 16 GB RAM - NVIDIA GeForce GTX 1050 Ti 4GB

  4. #4
    Member
    Join Date
    Sep 2008
    Location
    Germany
    Posts
    406
    Rep Power
    56

    Re: Connecting to an Established Server

    Hi everyone there,

    i have to say that i'm a little bit confusion.
    just, i was reading Peter here, but i was not meant here.
    i think you could write for the other Peter : [Peter H] in order to differentiate both names !
    i get psychic problems, if i do ascertain that i cannot do this and this.

    Peter

  5. #5

    Re: Connecting to an Established Server

    Hi folks,

    This is my 4th attempt to send the mentioned attachment.

    It was in .doc form the first time, and rejected.

    My second attempt, with a .zip file, was rejected because it was a duplicate post.

    So was my third attempt, with totally different text.

    I've totally exited and come back in this time. My fingers are crossed.

    Regards,

    PeterH
    Attached Files Attached Files
    Thought for the day (in a broad Australian accent):<br />First of all yer gungadin. Afterwards yer gungadout.

  6. #6
    thinBasic MVPs
    Join Date
    May 2007
    Location
    UK
    Posts
    1,427
    Rep Power
    159

    Re: Connecting to an Established Server

    Peter can you post the "serverconnectmvb.tbasicc" file or do you really expect people to type all that in to try and help?

    can you send and receive on the same channel ?
    Home Desktop : Windows 7 - Intel Pentium (D) - 3.0 Ghz - 2GB - Geforce 6800GS
    Home Laptop : WinXP Pro SP3 - Intel Centrino Duo - 1.73 Ghz - 2 GB - Intel GMA 950
    Home Laptop : Windows 10 - Intel(R) Core(TM) i5-4210U CPU @ 1.70GHz, 2401 Mhz, 2 Core(s), 4 Logical Processor(s) - 4 GB - Intel HD 4400
    Work Desktop : Windows 10 - Intel I7 - 4 Ghz - 8GB - Quadro Fx 370

  7. #7

    Re: Connecting to an Established Server

    Hi Folks,

    It looks like my first post pertaining to the attachment, and all the text in it, was lost. Sorry.

    An attachment error was reported the first time because the attachment was a .doc file. When I tried again with a .zip attachment, the post was rejected because it was a duplicate, so I thought the text had been accepted the first time. It hadn't been.

    So I re-typed the the original text from memory, only to have it rejected because someone had replied to my one post that had got through. (That was Michael's reply, for which I am grateful.)

    With all the posting problems, I was extremely late already (having to take my wife somewhere important), so I just had to shut down and run.

    For the record, a summary of my latest rejected post is: (Reply to Michael after this)
    ----------------------------------------
    Thank you everyone for your responses.

    I rediscovered the TCP_ functions in the documentation. I had forgotten them because of information overload.

    I started from scratch, using them.

    I seem to be connecting to the server OK.

    I don't receive the response I expect. The expected response, as received by a PC-based terminal emulator, is shown on page 2 of the attachment in the former post that got through. Such emulators require only the destination IP address and port number to be specified by the user.

    I guess I must be mis-using either the TCP_Open or TCP_Recv command.

    All advice will be welcome and appreciated.

    Kind regards to all,
    ----------------------------------------

    Michael, thanks for your reply.

    I posted only a screen dump because I thought somebody would see what I was doing wrong just by inspection. I hadn't expected anyone to actually want to run my code and experiment with it.

    I appreciate your gesture. My code is attached. (I've also tried using TCP_Print instead of TCP_Send.) For test purposes, I am using a database on my local computer, so if by channel you mean port, the answer is I don't think I can send and receive on the same channel. Port 2300 is reserved for the database.

    Kind regards,

    Peter H
    Attached Files Attached Files
    Thought for the day (in a broad Australian accent):<br />First of all yer gungadin. Afterwards yer gungadout.

  8. #8

    Re: Connecting to an Established Server

    Hi Michael,

    Oops!

    When considering only the client end of my communication, port 2300 is immaterial. My mistake. After midnight here.

    To answer your question more accurately, I do not know if the client (thinBasic) program can send and receive on the same channel (port). However, I suspect that it can, because the database (server end) both sends and receives on only one port, being 2300.

    Kind regards,

    Peter H.
    Thought for the day (in a broad Australian accent):<br />First of all yer gungadin. Afterwards yer gungadout.

  9. #9
    thinBasic MVPs
    Join Date
    May 2007
    Location
    UK
    Posts
    1,427
    Rep Power
    159

    Re: Connecting to an Established Server

    Thanks for posting the script its sometimes quicker to look at what someone has done

    you have some mistakes

    TCPOpenFile has the error flag from TCP_OPEN not a handle, you should be using TCPFreeFile

    inBuffer = TCP_Recv(TCPFreeFile,6000)

    but I get an error 57 at work havent tried at home but try my version below see what you get.

    Mike

    oops slight bug but thanks Petr...now fixed
    Attached Files Attached Files
    Home Desktop : Windows 7 - Intel Pentium (D) - 3.0 Ghz - 2GB - Geforce 6800GS
    Home Laptop : WinXP Pro SP3 - Intel Centrino Duo - 1.73 Ghz - 2 GB - Intel GMA 950
    Home Laptop : Windows 10 - Intel(R) Core(TM) i5-4210U CPU @ 1.70GHz, 2401 Mhz, 2 Core(s), 4 Logical Processor(s) - 4 GB - Intel HD 4400
    Work Desktop : Windows 10 - Intel I7 - 4 Ghz - 8GB - Quadro Fx 370

  10. #10
    Senior Member Lionheart008's Avatar
    Join Date
    Sep 2008
    Location
    Germany, Bad Sooden-Allendorf
    Age
    51
    Posts
    934
    Rep Power
    109

    Re: Connecting to an Established Server

    hi peter h., michael, petr

    perhaps somebody can check the current tcp script again...

    I have started the debugger again and have got at line 28 of the script an error code 57 (again!)... the picture I am attaching...

    I have downloaded the current script and here the little mistake stills exists ... sorry... or my pc has a cold...

    best regards, Lionheart
    Attached Images Attached Images
    you can't always get what you want, but if you try sometimes you might find, you get what you need

Page 1 of 2 12 LastLast

Similar Threads

  1. Web server restart
    By ErosOlmi in forum Web and Forum
    Replies: 1
    Last Post: 29-01-2010, 23:51
  2. ThinBASIC COM Server
    By RobertoBianchi in forum Announcements
    Replies: 18
    Last Post: 31-07-2008, 16:15

Members who have read this thread: 0

There are no members to list at the moment.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •