Announcement

Collapse
No announcement yet.

Bind to 127.0.0.1

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

  • Bind to 127.0.0.1


    How do i bind a TCP server port to 127.0.0.1. I've been trying to use
    TCP OPEN SERVER ADDR, but it seems to want a Long, not a string.

    So which API do i use to convert the dotted-IP?

    Ta very much.

    - Nathan

  • #2
    You should be able to use the HOST ADDR statement, of just convert it directly:

    HOST ADDR "127.0.0.1" TO ip&

    or use

    ip& = &H0100007F

    as derived by:
    01 = 1
    00 = 0
    00 = 0
    7F = 127

    ------------------
    Lance
    PowerBASIC Support
    mailto:[email protected][email protected]</A>
    Lance
    mailto:[email protected]

    Comment


    • #3
      Solved.

      Code:
               LOCAL ip AS LONG
               hSock = FREEFILE
               HOST ADDR "127.0.0.1" TO ip
               TCP OPEN SERVER ADDR ip PORT 400 AS hSock TIMEOUT 90
      I was unaware that HOST ADDR... had to output to a variable in such
      a way. I was calling it like: TCP OPEN SERVER HOST ADDR "127.0.0.1"....
      which wasn't working.

      Thanks.

      - Nath

      Comment

      Working...
      X