Announcement

Collapse
No announcement yet.

Can't open 127.0.0.1 as client

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

  • Can't open 127.0.0.1 as client

    Hi,

    Does anyone know why the client code return error 57:

    '---------------------------------------
    'No lan card is installed in the machine
    'use 127.0.0.1 as host address (local host?)
    'I have sucessfully ping this address
    #COMPILE EXE
    DEFLNG A-Z

    FUNCTION PBMAIN()
    hTcp = FREEFILE
    TCP OPEN PORT 7 AT "127.0.0.1" AS hTcp
    MSGBOX STR$(ERR)
    TCP CLOSE hTcp
    END FUNCTION
    '--------------------------------------

    and the server code work fine:
    '---------------------------------------
    'No lan card is installed in the machine
    'so the current ip is 127.0.0.1
    #COMPILE EXE
    DEFLNG A-Z

    FUNCTION PBMAIN()
    HOST ADDR TO MyAddr
    hTcp = FREEFILE
    TCP OPEN SERVER ADDR MyAddr PORT 7 AS hTcp
    MSGBOX STR$(ERR)
    TCP CLOSE hTcp
    END FUNCTION
    '--------------------------------------

    I use eclient.bas and echoserv.bas for testing and get
    same result (server open ok and client open returns error 57)

    Thanks.

    Yang

    ------------------

  • #2
    Hi

    what OS are you using?

    Cheers

    Florent

    ------------------

    Comment


    • #3
      Thank you Florent,

      The OS is WIN2000 and WIN98. same error in these two OS.

      Yang.

      ------------------

      Comment


      • #4
        Get to a command prompt and ping 127.0.0.1. Also ping localhost.
        Either of these failing means you a TCP config problem.

        Can you connect to the internet from theses machines (using a modem)
        for example?

        Look for a the HOSTS file of your windows root directory. On NT
        it is located in winnt\system32\etc. Open the HOSTS file (no extension)
        and enter the following line if it isn't already:

        127.0.0.1 localhost

        Does that make a difference?

        Cheers

        Florent

        ------------------

        Comment


        • #5
          Florent,

          There is a line 127.0.0.1 localhost in my hosts file.

          The problem is I can open tcp as server but I can't connect to
          the server.

          The two sample program are run in the same computer.

          Thank you.

          Yang.

          ------------------

          Comment


          • #6
            I notice you do a

            HOST ADDR TO MyAddr in the server part

            What value does MyAddr return?

            Try opening the server with

            [sorry - this line should read]
            TCP OPEN SERVER PORT 7 AS hTcp

            instead of

            TCP OPEN SERVER MyAddr PORT 7 AS hTCP

            and connect with the client.

            I trust that the code you're using is not the demo code
            you've show above since all the server does is open a port
            and then closes the connection.

            In order to service clients you need to (in short):
            1- OPEN THE PORT
            2- use the TCP NOTIFY hTcp, ACCEPT to accept incoming connections


            Use the eclient/eserver code for testing not the code you posted above
            since the above can't work.

            The simplest test code for the server you should try:

            Code:
            #COMPILE EXE
            DEFLNG A-Z
            
            FUNCTION PBMAIN()
              LOCAL szBuffer AS ASCIIZ * 100
              LOCAL MyAddr&
              
              HOST ADDR "127.0.0.1" TO MyAddr&
              
              hTcp = FREEFILE
              TCP OPEN SERVER ADDR MyAddr& PORT 7 AS hTcp
              DO
                  TCP RECV hTcp, 100, szbuffer
                  SLEEP 10
              LOOP
              
            END FUNCTION
            Cheers

            Florent




            [This message has been edited by Florent Heyworth (edited September 13, 2000).]

            Comment


            • #7
              I use LOCALHOST instead of 127.0.0.1, the problem solved.

              Thanks.

              Yang.

              ------------------

              Comment

              Working...
              X