I use WSAConnect to connect to a server whose site has the prefix http: \ That is, it seems like the remote server should connect only on port 80. But, in fact, I see that for some pages of this http site - WSAConnect completes successfully on port 443.
Is it okay? Is this allowed?
WSAConnect is for low-level socket communication, for example low-level TCP/IP sockets.
Web servers use HTTP for communication with clients, such as browsers. HTTP is an application protocol on top of TCP/IP.
By default web servers use port 80 for plain HTTP communication. Webservers can also support HTTP over a secure connection (HTTPS). The default port for this is 443.
So it is perfectly fine for a web server to be reachable on port 80 and 443.
In general, a single server can be reachable on any number of ports. Different ports are used for different protocols.
Related
I'm creating my custom http server in C. sockaddr_in looks like this:
my_addr.sin_family = AF_INET;
my_addr.sin_port = htons(8080);
my_addr.sin_addr.s_addr = htol(INADDR_ANY);
And my question is how I can send my request without writing port after address.
For example 192.168.1.100 instead of 192.168.1.100:8080 or mydomain.loc instead of mydomain.loc:8080
how I can send my [HTTP] request without writing port after address[?]
You cannot communicate with a TCP endpoint without designating a specific port. Various kinds of services have conventional (default) ports, however, and oftentimes client software will use a service's conventional port if the user does not explicitly specify one.
The conventional port for the HTTP protocol is 80. If your server runs on that port, then it is likely that HTTP user agents such as web browsers will not require you to specify that port; instead they will silently insert it for you. You will need root / administrator privilege on the server machine to run the server software on port 80, or on any other port less than 1024.
If you want to access your custom server with any web browser then you must have to specify the listening port of your custom server because every browser will consider a server listening on port 80 on the address (URL) you provided.
how I can send my [HTTP] request without writing port after address[?]
And if you want to provide only the host IP address and using the 8080 port as default listening port of your server, you can make a simple custom client. Pass the host URL i.e. 192.168.1.100 to that client. In the body of client, connect the socket to 192.168.1.100 and 8080 address. Client will send query to your custom server and will save the reply in .html file. You can then open this file with browser.
I have 4 Azure VMs which are part of the same resource group and virtual network. 3 of them are running SQL Sever and 1 of them is configured as a domain controller. The 3 SQL VMs are getting there DNS from the DC.
The VMs can log into the domain and see each other on the network. When I try to use connect to SQL instances across the virtual network, however, I receive a network path not found error.
I have renamed the instances and even tried removing and re-installing them. So I am sure it is a network issue, and not a SQL Server problem. I also can't connect via IP address, so it doesn't seem to be DNS.
The instances are all default instances and are connected on 1433, the VMs all have TCP 1433 endpoints and Windows Firewall is turned off.
I think you need to Enable the Port from Azure Services As well
The instances are all default instances and are connected on 1434, the
VMs all have TCP 1433 endpoints, and Windows Firewall is turned off.
Ensure you have both ports open in all machines. 1433, 1434
Also remember that disable windows firewall is just a temporary thing, you should re-enable it once the connection test pass.
Note that depending of your kind of connection/services you also should open:
1433: / TCP / UDP
80: For sync over HTTP / TCP
443: SQL Server default instance running over an HTTPS endpoint / TCP
4022: Service Broker / TCP
135: Transact-SQL debugger / TCP
7022: Defacto database mirroring / TCP
2383: SQL Server Analysis Services
2382: connection requests to a named instance of Analysis Services
I am developing a private chat application. My Server side code(NodeJs + Express + Socket.io) is running on port 7000. And my client side code(AngularJs) is running on port 8000.
When I am trying to connect my socket client(running in port 8000) to socket server(which is running on port 7000), I am getting 404, which is obvious.
I have following questions related to this:-
I am now unable to figure out how I can make Socket client # port 8000 listen/get connect to socket server # port 7000.
Will there be any impact on all this configuration if tomorrow in production I will introduce Ngnix which will be running on port 80?
Thanks,
Vikram
Found the solution.
Instead of include socket.io in your HTML as :-
You can also include it as
I have a server.c I can connect to it if I know the port that I assign to the server; lets say 6000. I go to FireFox and type 127.0.0.1:6000 and I can connect perfectly.
How do I build my server that a client will type 127.0.0.1 on a browser and then the server will assign the port or notify the user on the browser to type the port?
Perhaps I don't fully understand servers but it seems to me that the client must know the port from the get-go.
You need a port to connect. HTTP connects to port 80 by default and that's why you can get away by typing 127.0.0.1 into your browser.
The default standard port is 80 for an IP in a browser. Maybe your program (server.c) waits a request with the default port 80, and transfer the request into another user-defined port.
I am trying to use this c socket class, but it only works when I use it on my own computer.
Desktop only
Server is started like this: cSocketServer -p:2030 -i:192.168.178.22
Client connects: cSocketclient -p:2030 -s:192.168.178.22
Works fine.
Desktop server, laptop client
Server: cSocketServer -p:2030 -i:192.168.178.22
Client: cSocketclient -p:2030 -s:192.168.178.22
Exact same as above, but this fires the connect failed: 10060 error. Which essentially means it timed out.
Desktop only (external address)
Server: cSocketServer -p:2030 -i:192.168.178.22
Client: cSocketclient -p:2030 -s:xx.xx.xx.xx
Where xx.xx.xx.xx is my external ip address.
Same error: connect failed: 10060. Port 2030 is definitely open and accessible, because I tested it with a few unrelated applications that allow their users to choose their own ports (like utorrent). While those run, whatismyip.org states port 2030 is open. But when I run my application it sais it Timed-out. Those applications do not have any special privileges in the firewall.
But even if I did mess up some firewall/router settings (which I'm fairly sure I didn't) that wouldn't explain why I can't connect to the server from within my local network. Other services (such as file sharing) work fine so there is definitely a connection between the 2 computers.
Both client and server run on windows 7 64-bit.
Also; for some reason, each client that connects gets their own inbound port assigned or something? Is that normal? When clients connect the server states;
Accepted client: 192.168.178.22:55156
Accepted client: 192.168.178.22:55164
Accepted client: 192.168.178.22:55176
What's that all about?
If two TCP connections have the same source IP, destination IP, source port, and destination port, there would be no way to tell them apart. To ensure they differ somewhere, clients typically assign a unique source port to every outbound connection they make.
As for the errors, you really need to do some troubleshooting. Do the listening sockets show up in a 'netstat'? Do you get the same problem with the firewalls turned off? Are the server and client on the same LAN (for the internal address case)? Is port forwarding enabled and working in the router (for the external address case)?
My bet is that the external address case won't work because you haven't configured the port to be forwarded by your router or your router doesn't support hairpin (local access to external IP). Other programs may work because they support UPnP or don't rely on hairpin (all access to external IPs come from outside your LAN).
I have no immediate explanation for why your desktop-to-laptop won't work inside your LAN. Are you sure both computers are in the same LAN? Can they ping each other?
Get rid of the -i argument to the server, or specify 0.0.0.0 and fix the code so that isn't considered an error, which is itself an error.