Can curl
make a connection to any TCP ports not just HTTP/HTTPS
I need to check for an open port, for example: 11740
.
Is this possible?
Connections - Everything curl. Most of the protocols you use with curl speak TCP. With TCP, a client such as curl must first figure out the IP address(es) of the host you want to communicate with, then connect to it. "Connecting to it" means performing a TCP protocol handshake.
Such connections implicitly start out using SSL/TLS and as such servers and clients use TCP port 465 to communicate with each other.
Short answer - NO, you can't have different TCP/HTTP/Websocket servers running on the same port. Longish answer - Both websockets and HTTP work on top of TCP. So you can think of a http server or websocket server as a custom TCP server (with some state mgmt and protocol specific encoding/decoding).
curl simply ignores the port and goes with 443. Of-course, this causes the DNS cache to miss and I end-up using the public DNS IP...
Yes, it's possible, the syntax is curl [protocol://]<host>[:port]
, for example:
curl example.com:1234
If you're using Bash, you can also use pseudo-device /dev
files to open a TCP connection, e.g.:
exec 5<>/dev/tcp/127.0.0.1/1234 echo "send some stuff" >&5 cat <&5 # Receive some stuff.
See also: More on Using Bash's Built-in /dev/tcp File (TCP/IP).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With