How to run Boost.Asio server on port 80? - c++

I have a simple boost.asio server which I am trying to run it on port 80. I am running the code inside a try-catch and I get a "bind" exception error. The value of boost::error_code is 13 which I think is "access denied".
I am running the code from Xcode on Mac running Yosemite. I also tried to run Xcode with sudo.
How can I fix this issue ?

Run as root.
The problem is that you don't have the permission to bind to a privileged port (<1024 on most systems).
If you're certain that the child process of Xcode runs as root, find out which process is already listening on port 80 (lsof and netstat)

Related

Couldn't connect web socket client to websocket server on local host windows 10

I have an application signed for microsoft store which starts a web socket server on localhost (0.0.0.0:8081) on launching. Then I run python script with websocket client on the same host and try to connect to server (ws://127.0.0.1:8081) and it couldn't connect. But I can connect without any problems if I run this python script from another PC. Actually it works fine on local PC on another platforms: Win7, MacOS.
What i tried:
disabled windows firewall and defender
tried to add exception for application using CheckNetIsolation LoopbackExempt
tried to connect using different ip (0.0.0.0, 127.0.0.1, pc name)
It seems like I have to switch/set on/off some option for application or win10, but I can't find it
Thanks for help in advance
I found a solution https://learn.microsoft.com/en-us/windows/iot-core/develop-your-app/loopback
if you want to connect smth to win application on win 10 you should run
CheckNetIsolation.exe LoopbackExempt -is -n=your application
permanently
the best way to add it to start up menu

Vagrant not working - timeout while waiting for the machine to boot

I have installed the latest versions of Virtualbox v.5.2.6 and Vagrant v.2.0.1 on the windows machine with the Intel-Core-i5-4210U-Processor #1.70Ghz 2.40Ghz. I have added the homestead box by running the command:
vagrant box add laravel/homestead
But, on running the vagrant up it runs fine until this point:
Timed out while waiting for the machine to boot. This means that
Vagrant was unable to communicate with the guest machine within the
configured ("config.vm.boot_timeout" value) time period.
If you look above, you should be able to see the error(s) that Vagrant
had when attempting to connect to the machine. These errors are
usually good hints as to what may be wrong.
If you're using a custom box, make sure that networking is properly
working and you're able to connect to the machine. It is a common
problem that networking isn't setup properly in these boxes. Verify
that authentication configurations are also setup properly, as well.
If the box appears to be booting properly, you may want to increase
the timeout ("config.vm.boot_timeout") value.
On running the vagrant ssh-config I get:
Host homestead-7
HostName 127.0.0.1
User vagrant
Port 2222
UserKnownHostsFile /dev/null
StrictHostKeyChecking no
PasswordAuthentication no
IdentityFile C:/Users/MyUser/.vagrant.d/insecure_private_key
IdentitiesOnly yes
LogLevel FATAL
ForwardAgent yes
I have looked around and tried out different things, among others, to uninstall and install again both vagrant and virtualbox, but couldn't find any solution. How can I get this working?

Linux denies permission on socket bind using boost asio

I'm having a problem binding a socket and I get permision denied when running the program as a user. this line of code generates an error.
_acceptor = new boost::asio::ip::tcp::acceptor(io, boost::asio::ip::tcp::endpoint(boost::asio::ip::tcp::v4(), serverPort));
the error is
terminate called after throwing an instance of 'boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<boost::system::system_error> >'
what(): bind: Permission denied
However, if I run as root it works fine. I've tried disabling apparmor and firewall with
sudo service apparmor stop
sudo ufw disable
but I still have the problem. Am I missing something that could deny permision?
I'd really like to figure this out as I don't like running my IDE and an unproven program as root.
I'm running xubuntu 13.10 with all updates installed.
On unix systems, the first 1024 port are restricted to the root user only so if serverPort < 1024 you should try something > 1024

Tomcat 404 error trying to access webapp [duplicate]

Strange things happen. I can start Tomcat from both Eclipse and startup.sh. Runnig from Eclipse I can access localhost:8080 while running from startup.sh I cant. What could be the problem? Ubuntu 11.10. From Eclipse netstat displays 127.0.0.1:8080 as ESTABLISHED and from startup.sh as CLOSE_WAIT.
The problem was caused by incorrect installation. Everything is solved. Close.

Using Eclipse to remotely debug with gdbserver

Does anyone know why I can't use Eclipse CDT to remotely debug a device when I manage it on the command-line with gdb using target remote command? I do get a warning when connecting, but other than that it seems to work fine.
With Eclipse I should have the correct settings and gdbserver informs me on the remote machine that a connection was establised but after that Eclipse gives an error: 'Launching Debug' has encountered a problem. The request failed: Target is not responding (timed out). Remote device also says "Killing inferior" (which I don't get with gdb). The error log shows nothing else either.
I am using the same process, binary and gdb executable in both cases and connecting to the same device & port. I'm using gdb 7.1 and the host is 64-bit Ubuntu Lucid.
I had same issue and found that iptables was generating issues.
Have you tried stopping or disabling your firewall? In case of iptables you have to do:
/etc/init.d/iptables stop
On the other hand, after you start your application (before connecting your debugger) have you checked the debug port availability through netstat?
#On linux
netstat -nap
#On windows
netstat -nab
Hope to help.