Bind error in Ring sample

127 views
Skip to first unread message

CalmoSoft

unread,
Sep 1, 2021, 2:30:06 AM9/1/21
to The Ring Programming Language
Hello Mahmoud et All,

When I run Ring/samples/UsingSockets/tcpserver.ring I get next error message:

--------------------------------------------------------------------------------------------------
Line 4 Bind Error 
In bind() in file C:/Ring/samples/UsingSockets/tcpserver.ring 
--------------------------------------------------------------------------------------------------

The code is:

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

load "sockets.ring"

sock = socket(AF_INET,SOCK_STREAM,0)

bind(sock,"127.0.0.1",5050)

listen(sock,5)

ns = accept(sock)

send(ns,"Hello Client")

msg = recv(ns,1024)

? "Client Say >> " + msg

close(ns)

close(sock)

? "Socket connection closed"

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



Have a nice day and good work.

Greetings,
Gal Zsolt
(~ CalmoSoft ~)

Ilir

unread,
Sep 1, 2021, 11:17:32 AM9/1/21
to The Ring Programming Language
Hello Gal,

if you get bind error, that means some other process uses socket 5050 or it is blocked by firewall (it will not be reported unless your configuration says so).

Check if you have running ring process which wasn't stopped correctly and still uses socket 5050 or use netstat -a (dos prompt) command to find all occupied ports.

CalmoSoft

unread,
Sep 1, 2021, 11:40:28 AM9/1/21
to The Ring Programming Language
Hello Ilir,

Thanks for your useful suggestions, I try to do them.

CalmoSoft

unread,
Sep 2, 2021, 1:00:03 AM9/2/21
to The Ring Programming Language
Hello Ilir,

I use port not occupied, but the program still does not work properly.

Ilir

unread,
Sep 2, 2021, 4:05:58 AM9/2/21
to The Ring Programming Language
Hello Gal,

change the port in Ring source to 8081. This port (including 8080) is usually used by proxy servers, other Ring samples use them without a problem. Something is blocking port 5050 on your machine, I can't know what without physical access to your machine.

CalmoSoft

unread,
Sep 2, 2021, 5:20:07 AM9/2/21
to The Ring Programming Language
Hello Ilir,

I changed the port to 8081 but still get same error message.

Ilir

unread,
Sep 2, 2021, 5:26:04 AM9/2/21
to The Ring Programming Language
Hello Gal,

what happens if you run samples\webserver\ringlibuv\webserver.ring?

CalmoSoft

unread,
Sep 2, 2021, 7:00:03 AM9/2/21
to The Ring Programming Language
Hello Ilir,

When I run  samples\webserver\ringlibuv\webserver.ring I get next message:

-------------------------------------------------------
RingLibuv - Simple Web Server!
Listen error address already in use
-------------------------------------------------------

Ilir

unread,
Sep 2, 2021, 7:13:44 AM9/2/21
to The Ring Programming Language
Hello Gal,

as the message says:  Listen error address already in use. Something is running on your machine using all ports you tried. What netstat -a says about ports 5050,8080,8081? Can you run task manager, performance, open resource  monitor, network to see which processes are using above ports?

CalmoSoft

unread,
Sep 2, 2021, 9:25:04 AM9/2/21
to The Ring Programming Language
Hello Ilir,

Here is the list of used ports:

------------------------------------------------------------------------------------------
C:\Users\User>netstat -a

Active Connections

  Proto  Local Address          Foreign Address        State
  TCP    0.0.0.0:135            CalmoSoft:0            LISTENING
  TCP    0.0.0.0:445            CalmoSoft:0            LISTENING
  TCP    0.0.0.0:808            CalmoSoft:0            LISTENING
  TCP    0.0.0.0:5040           CalmoSoft:0            LISTENING
  TCP    0.0.0.0:5061           CalmoSoft:0            LISTENING
  TCP    0.0.0.0:5071           CalmoSoft:0            LISTENING
  TCP    0.0.0.0:5357           CalmoSoft:0            LISTENING
  TCP    0.0.0.0:7680           CalmoSoft:0            LISTENING
  TCP    0.0.0.0:8080           CalmoSoft:0            LISTENING
  TCP    0.0.0.0:8081           CalmoSoft:0            LISTENING
  TCP    0.0.0.0:9001           CalmoSoft:0            LISTENING
  TCP    0.0.0.0:17500          CalmoSoft:0            LISTENING
  TCP    0.0.0.0:49664          CalmoSoft:0            LISTENING
  TCP    0.0.0.0:49665          CalmoSoft:0            LISTENING
  TCP    0.0.0.0:49666          CalmoSoft:0            LISTENING
  TCP    0.0.0.0:49667          CalmoSoft:0            LISTENING
  TCP    0.0.0.0:49668          CalmoSoft:0            LISTENING
  TCP    0.0.0.0:49670          CalmoSoft:0            LISTENING
  TCP    0.0.0.0:49671          CalmoSoft:0            LISTENING
  TCP    0.0.0.0:49672          CalmoSoft:0            LISTENING
  TCP    127.0.0.1:843          CalmoSoft:0            LISTENING
  TCP    127.0.0.1:17600        CalmoSoft:0            LISTENING
  TCP    127.0.0.1:64779        CalmoSoft:64780        ESTABLISHED
  TCP    127.0.0.1:64780        CalmoSoft:64779        ESTABLISHED
  TCP    127.0.0.1:64791        CalmoSoft:64792        ESTABLISHED
  TCP    127.0.0.1:64792        CalmoSoft:64791        ESTABLISHED
  TCP    192.168.0.15:139       CalmoSoft:0            LISTENING
  TCP    192.168.0.15:49699     20.199.120.151:https   ESTABLISHED
  TCP    192.168.0.15:49836     20.199.120.182:https   ESTABLISHED
  TCP    192.168.0.15:50254     20.54.232.160:https    ESTABLISHED
  TCP    192.168.0.15:50255     40.126.31.8:https      ESTABLISHED
  TCP    192.168.0.15:50256     h3-c04-b:http          TIME_WAIT
  TCP    192.168.0.15:50259     40.126.31.8:https      ESTABLISHED
  TCP    192.168.0.15:50267     204.79.197.222:https   ESTABLISHED
  TCP    192.168.0.15:50268     192.168.0.13:ms-do     SYN_SENT
  TCP    192.168.0.15:50490     ec2-52-48-255-75:8282  ESTABLISHED
  TCP    192.168.0.15:56400     162.125.19.131:https   ESTABLISHED
  TCP    192.168.0.15:60152     162.125.19.130:https   ESTABLISHED
  TCP    192.168.0.15:60162     um15:http              TIME_WAIT
  TCP    192.168.0.15:62366     93.184.220.29:http     CLOSE_WAIT
  TCP    [::]:135               CalmoSoft:0            LISTENING
  TCP    [::]:445               CalmoSoft:0            LISTENING
  TCP    [::]:808               CalmoSoft:0            LISTENING
  TCP    [::]:5357              CalmoSoft:0            LISTENING
  TCP    [::]:7680              CalmoSoft:0            LISTENING
  TCP    [::]:9001              CalmoSoft:0            LISTENING
  TCP    [::]:17500             CalmoSoft:0            LISTENING
  TCP    [::]:49664             CalmoSoft:0            LISTENING
  TCP    [::]:49665             CalmoSoft:0            LISTENING
  TCP    [::]:49666             CalmoSoft:0            LISTENING
  TCP    [::]:49667             CalmoSoft:0            LISTENING
  TCP    [::]:49668             CalmoSoft:0            LISTENING
  TCP    [::]:49672             CalmoSoft:0            LISTENING
  TCP    [::1]:49669            CalmoSoft:0            LISTENING
  TCP    [2a02:ab88:1b81:5e00:6953:67fd:f95d:367e]:49465  bud02s23-in-x05:https  ESTABLISHED
  TCP    [2a02:ab88:1b81:5e00:6953:67fd:f95d:367e]:50252  bud02s35-in-x03:https  ESTABLISHED
  TCP    [2a02:ab88:1b81:5e00:6953:67fd:f95d:367e]:50257  [2620:1ec:c11::200]:https  TIME_WAIT
  TCP    [2a02:ab88:1b81:5e00:6953:67fd:f95d:367e]:50258  [2620:1ec:c11::200]:https  TIME_WAIT
  TCP    [2a02:ab88:1b81:5e00:6953:67fd:f95d:367e]:50260  [2603:1026:302:c8::2]:https  ESTABLISHED
  TCP    [2a02:ab88:1b81:5e00:6953:67fd:f95d:367e]:50261  [2603:1026:300:78::2]:https  TIME_WAIT
  TCP    [2a02:ab88:1b81:5e00:6953:67fd:f95d:367e]:50262  [2620:1ec:c11::200]:https  ESTABLISHED
  TCP    [2a02:ab88:1b81:5e00:6953:67fd:f95d:367e]:50264  [2620:1ec:8f8::254]:https  ESTABLISHED
  TCP    [2a02:ab88:1b81:5e00:6953:67fd:f95d:367e]:50265  [2620:1ec:bdf::254]:https  ESTABLISHED
  TCP    [2a02:ab88:1b81:5e00:6953:67fd:f95d:367e]:50266  [2606:2800:133:206e:1315:22a5:2006:24fd]:https  ESTABLISHED
  TCP    [2a02:ab88:1b81:5e00:6953:67fd:f95d:367e]:50269  [2620:100:6022:13::a27d:420d]:https  ESTABLISHED
  TCP    [2a02:ab88:1b81:5e00:9591:fdb9:7745:504a]:51705  g2a02-26f0-010e-0399-0000-0000-0000-0057:https  ESTABLISHED
  TCP    [2a02:ab88:1b81:5e00:9591:fdb9:7745:504a]:62363  g2a02-26f0-010e-02a4-0000-0000-0000-4106:https  ESTABLISHED
  TCP    [2a02:ab88:1b81:5e00:9591:fdb9:7745:504a]:62364  g2a02-26f0-010e-02a4-0000-0000-0000-4106:https  ESTABLISHED
  TCP    [2a02:ab88:1b81:5e00:9591:fdb9:7745:504a]:62367  g2a02-26f0-010e-03a0-0000-0000-0000-3114:http  ESTABLISHED
  TCP    [2a02:ab88:1b81:5e00:9591:fdb9:7745:504a]:62368  g2a02-26f0-010e-03a0-0000-0000-0000-3114:http  ESTABLISHED
  TCP    [2a02:ab88:1b81:5e00:9591:fdb9:7745:504a]:62369  g2a02-26f0-010e-03a0-0000-0000-0000-3114:http  ESTABLISHED
  TCP    [2a02:ab88:1b81:5e00:9591:fdb9:7745:504a]:62370  g2a02-26f0-010e-03a0-0000-0000-0000-3114:http  ESTABLISHED
  TCP    [2a02:ab88:1b81:5e00:9591:fdb9:7745:504a]:62371  g2a02-26f0-010e-03a0-0000-0000-0000-3114:http  ESTABLISHED
  TCP    [2a02:ab88:1b81:5e00:9591:fdb9:7745:504a]:62372  g2a02-26f0-010e-03a0-0000-0000-0000-3114:http  ESTABLISHED
  TCP    [2a02:ab88:1b81:5e00:9591:fdb9:7745:504a]:62373  [2a01:8f8:a06:c04::b90a:7c68]:https  CLOSE_WAIT
  TCP    [2a02:ab88:1b81:5e00:9591:fdb9:7745:504a]:62381  g2a02-26f0-010e-02a4-0000-0000-0000-4106:https  ESTABLISHED
  TCP    [2a02:ab88:1b81:5e00:9591:fdb9:7745:504a]:63072  rb-in-f188:5228        ESTABLISHED
  UDP    0.0.0.0:3702           *:*
  UDP    0.0.0.0:3702           *:*
  UDP    0.0.0.0:3702           *:*
  UDP    0.0.0.0:3702           *:*
  UDP    0.0.0.0:5050           *:*
  UDP    0.0.0.0:5353           *:*
  UDP    0.0.0.0:5353           *:*
  UDP    0.0.0.0:5353           *:*
  UDP    0.0.0.0:5353           *:*
  UDP    0.0.0.0:5353           *:*
  UDP    0.0.0.0:5355           *:*
  UDP    0.0.0.0:17500          *:*
  UDP    0.0.0.0:49174          *:*
  UDP    0.0.0.0:49666          *:*
  UDP    0.0.0.0:51273          *:*
  UDP    0.0.0.0:54548          *:*
  UDP    0.0.0.0:55132          *:*
  UDP    127.0.0.1:1900         *:*
  UDP    127.0.0.1:49668        *:*
  UDP    127.0.0.1:54553        *:*
  UDP    192.168.0.15:137       *:*
  UDP    192.168.0.15:138       *:*
  UDP    192.168.0.15:1900      *:*
  UDP    192.168.0.15:54552     *:*
  UDP    [::]:3702              *:*
  UDP    [::]:3702              *:*
  UDP    [::]:3702              *:*
  UDP    [::]:3702              *:*
  UDP    [::]:5353              *:*
  UDP    [::]:5353              *:*
  UDP    [::]:5353              *:*
  UDP    [::]:5355              *:*
  UDP    [::]:49174             *:*
  UDP    [::]:49667             *:*
  UDP    [::]:51273             *:*
  UDP    [::]:54549             *:*
  UDP    [::1]:1900             *:*
  UDP    [::1]:54551            *:*
  UDP    [fe80::55d1:2e50:22a8:c815%3]:1900  *:*
  UDP    [fe80::55d1:2e50:22a8:c815%3]:54550  *:*

C:\Users\User>
------------------------------------------------------------------------------------------

Ilir

unread,
Sep 2, 2021, 10:06:19 AM9/2/21
to The Ring Programming Language
Hello Gal,

as you can see, ports 5050,8080,8081 are used. Use resource monitor to check which process occupies which port and shut it down. Or simply restart your computer and see what will happen.

CalmoSoft

unread,
Sep 2, 2021, 10:25:03 AM9/2/21
to The Ring Programming Language
Hello Ilir,

I restarted the computer and still got same error.
How can I use resource monitor?

CalmoSoft

unread,
Sep 2, 2021, 10:35:06 AM9/2/21
to The Ring Programming Language
Hello Ilir,

Now I know how can I use resource monitor (resmon.exe)
Reply all
Reply to author
Forward
0 new messages